From: Rafael Kitover Date: Fri, 5 Mar 2010 21:53:00 +0000 (-0500) Subject: Sybase: set inflate_datetime => 1 for 'AS getdate()' computed columns X-Git-Tag: 0.06000~61 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0faae4b8a8a08f1442ea2cf7dcd03bc14ef38cd3;p=dbsrgits%2FDBIx-Class-Schema-Loader.git Sybase: set inflate_datetime => 1 for 'AS getdate()' computed columns --- diff --git a/Changes b/Changes index 4d93cc2..8f8b2aa 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,7 @@ Revision history for Perl extension DBIx::Class::Schema::Loader + - set inflate_datetime => 1 for 'AS getdate()' computed columns in + Sybase - preliminary Firebird support - use introspection pragmas instead of regexes to introspect SQLite (hobbs) diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm b/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm index 145eef9..186581f 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm @@ -253,6 +253,10 @@ WHERE o.name = @{[ $dbh->quote($table) ]} AND o.type = 'U' if ($default =~ /^AS \s+ (\S+)/ix) { my $function = $1; $res->{default_value} = \$function; + + if ($function =~ /^getdate\b/) { + $res->{inflate_datetime} = 1; + } } elsif ($default =~ /^DEFAULT \s+ (\S+)/ix) { my ($constant_default) = $1 =~ /^['"\[\]]?(.*?)['"\[\]]?\z/; diff --git a/t/15sybase_common.t b/t/15sybase_common.t index 749aac3..83b24fe 100644 --- a/t/15sybase_common.t +++ b/t/15sybase_common.t @@ -65,7 +65,7 @@ my $tester = dbixcsl_common_tests->new( }, ], drop => [ qw/ sybase_loader_test1 sybase_loader_test2 / ], - count => 36, + count => 37, run => sub { my ($schema, $monikers, $classes) = @_; @@ -143,6 +143,8 @@ my $tester = dbixcsl_common_tests->new( is_deeply $rsrc->column_info('the_decimal')->{size}, [6,3], 'size for DECIMAL(precision, scale) is correct'; + is $schema->resultset($monikers->{loader_test35})->result_source->column_info('a_function')->{inflate_datetime}, 1, + 'AS getdate() columns get inflate_datetime => 1'; }, }, );