Author: spadkins
Date: Tue Sep 28 07:13:44 2010
New Revision: 14450
Modified:
p5ee/trunk/App-Repository/lib/App/RepositoryShell.pm
Log:
support the display of NULL values
Modified: p5ee/trunk/App-Repository/lib/App/RepositoryShell.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/RepositoryShell.pm (original)
+++ p5ee/trunk/App-Repository/lib/App/RepositoryShell.pm Tue Sep 28
07:13:44 2010
@@ -265,6 +265,8 @@
print "============================================================\n";
print "help - [synonym: ?] show this list of commands\n";
print "select/insert/update/delete/create/alter ... - run a sql
statement\n";
+ print "desc[ribe] <table> - show columns of a table\n";
+ print "show (repositories|tables|columns) - list all of the objects
named\n";
print "repository [<name>] - set or show the current repository\n";
#print "table [<name>] - set or show the current table\n";
#print "param [<name>] - set or show the current params\n";
@@ -730,7 +732,7 @@
if (! defined $autoformat[$c]) {
$autoformat[$c] = {
max_length => 0,
- type => 2, # 0=string, 1=float, 2=integer
+ type => 0, # 0=string, 1=float, 2=integer
min => undef,
max => undef,
};
@@ -754,31 +756,37 @@
for ($r = 0; $r <= $#$rows; $r++) {
$row = $rows->[$r];
- if ($c <= $#$row && defined $row->[$c]) {
+ if ($c <= $#$row) {
$elem = $row->[$c];
- $len = length($elem);
- if ($elem =~ /^-?[0-9]*\.[0-9]+$/) { # float
- $len = length(sprintf("%.$App::options{decimals}f",$elem));
- $f->{type} = 1 if ($f->{type} > 1);
- if (!defined $f->{min} || $elem < $f->{min}) {
- $f->{min} = $elem;
- }
- if (!defined $f->{max} || $elem < $f->{max}) {
- $f->{max} = $elem;
- }
+ if (!defined $elem) {
+ $len = 4; # length("NULL")
+ $f->{max_length} = $len if ($len > $f->{max_length});
}
- elsif ($elem =~ /^-?[0-9]+$/) { # integer
- if (!defined $f->{min} || $elem < $f->{min}) {
- $f->{min} = $elem;
+ else {
+ $len = length($elem);
+ if ($elem =~ /^-?[0-9]*\.[0-9]+$/) { # float
+ $len =
length(sprintf("%.$App::options{decimals}f",$elem));
+ $f->{type} = 1 if ($f->{type} > 1);
+ if (!defined $f->{min} || $elem < $f->{min}) {
+ $f->{min} = $elem;
+ }
+ if (!defined $f->{max} || $elem < $f->{max}) {
+ $f->{max} = $elem;
+ }
}
- if (!defined $f->{max} || $elem < $f->{max}) {
- $f->{max} = $elem;
+ elsif ($elem =~ /^-?[0-9]+$/) { # integer
+ if (!defined $f->{min} || $elem < $f->{min}) {
+ $f->{min} = $elem;
+ }
+ if (!defined $f->{max} || $elem < $f->{max}) {
+ $f->{max} = $elem;
+ }
}
+ else {
+ $f->{type} = 0;
+ }
+ $f->{max_length} = $len if ($len > $f->{max_length});
}
- else {
- $f->{type} = 0;
- }
- $f->{max_length} = $len if ($len > $f->{max_length});
}
}
$self->determine_sprintf_fmt($f);
@@ -795,9 +803,17 @@
for ($r = 0; $r <= $#$rows; $r++) {
$row = $rows->[$r];
for ($c = 0; $c <= $#$row; $c++) {
- $format = $autoformat[$c]->{fmt} || "%s";
- print $fh " " if ($c > 0);
- printf($fh $format, $row->[$c]);
+ $elem = $row->[$c];
+ if (defined $elem) {
+ $format = $autoformat[$c]->{fmt} || "%s";
+ print $fh " " if ($c > 0);
+ printf($fh $format, $row->[$c]);
+ }
+ else {
+ $format = $autoformat[$c]->{title_fmt} || "%s";
+ print $fh " " if ($c > 0);
+ printf($fh $format, "NULL");
+ }
}
print $fh "\n";
}