From: Rafael Kitover Date: Wed, 19 Oct 2011 19:53:07 +0000 (-0400) Subject: update SQLAnywhere ODBC driver for default \"null" X-Git-Tag: 0.07011~31 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=eea428f2924e07c7103fa01a31a3b8e1ebc15401;p=dbsrgits%2FDBIx-Class-Schema-Loader.git update SQLAnywhere ODBC driver for default \"null" Previously a fix was committed to support DEFAULT NULL in Pg, this broke the SQLAnywhere ODBC driver tests, because ::DBI::SQLAnywhere had a fixup for default_value => \"NULL", and it is now lowercased. Only the ODBC driver sets nullable columns DEFAULT NULL, so this fixup has been moved to ::DBI::ODBC::SQL_Anywhere, with the correct case. All SQL Anywhere tests pass again. --- diff --git a/lib/DBIx/Class/Schema/Loader/DBI/ODBC/SQL_Anywhere.pm b/lib/DBIx/Class/Schema/Loader/DBI/ODBC/SQL_Anywhere.pm index 32bfb3a..f4f0ec0 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/ODBC/SQL_Anywhere.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/ODBC/SQL_Anywhere.pm @@ -21,6 +21,23 @@ Proxy for L when using L for usage information. +=cut + +sub _columns_info_for { + my $self = shift; + + my $result = $self->next::method(@_); + + while (my ($col, $info) = each %$result) { + # The ODBC driver sets the default value to NULL even when it was not specified. + if (ref $info->{default_value} && ${ $info->{default_value} } eq 'null') { + delete $info->{default_value}; + } + } + + return $result; +} + =head1 SEE ALSO L, @@ -39,3 +56,4 @@ the same terms as Perl itself. =cut 1; +# vim:et sw=4 sts=4 tw=0: diff --git a/lib/DBIx/Class/Schema/Loader/DBI/SQLAnywhere.pm b/lib/DBIx/Class/Schema/Loader/DBI/SQLAnywhere.pm index e92cfe6..c6b119c 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/SQLAnywhere.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/SQLAnywhere.pm @@ -142,8 +142,6 @@ EOF $info->{data_type} = 'real'; } - delete $info->{default_value} if ref($info->{default_value}) eq 'SCALAR' && ${ $info->{default_value} } eq 'NULL'; - if ((eval { lc ${ $info->{default_value} } }||'') eq 'current timestamp') { ${ $info->{default_value} } = 'current_timestamp';