[Jifty-commit] r2019 - jifty/trunk/lib/Jifty/Script
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Wed Oct 11 12:10:36 EDT 2006
Author: gaal
Date: Wed Oct 11 12:10:36 2006
New Revision: 2019
Modified:
jifty/trunk/lib/Jifty/Script/Schema.pm
Log:
* Classify databases failing an SQL::ReservedWords check for nicer output
Modified: jifty/trunk/lib/Jifty/Script/Schema.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/Schema.pm (original)
+++ jifty/trunk/lib/Jifty/Script/Schema.pm Wed Oct 11 12:10:36 2006
@@ -516,6 +516,19 @@
Jifty->handle->connect();
}
+sub __parenthesize {
+ if (not defined $_[0]) { return () }
+ if (@_ == 1) { return $_[0] }
+ return "(" . (join ", ", @_) . ")";
+}
+
+sub _classify {
+ my %dbs;
+ # Guess names of databases + their versions by breaking on last space,
+ # e.g., "SQL Server 7" is ("SQL Server", "7"), not ("SQL", "Server 7").
+ push @{ $dbs{$_->[0]} }, $_->[1] for map { [ split /\s+(?!.*\s)/, $_, 2 ] } @_;
+ return map { join " ", $_, __parenthesize(@{ $dbs{$_} }) } sort keys %dbs;
+}
sub _check_reserved {
my $self = shift;
@@ -526,7 +539,7 @@
$log->error( $model . ": "
. $col->name
. " is a reserved word in these SQL dialects: "
- . join( ', ', @{ $_SQL_RESERVED{ lc( $col->name ) } } ) );
+ . join( ', ', _classify(@{ $_SQL_RESERVED{ lc( $col->name ) } }) ) );
}
}
}
More information about the Jifty-commit
mailing list