[Bast-commits] r7948 - in branches/DBIx-Class-Schema-Loader/current:
lib/DBIx/Class/Schema lib/DBIx/Class/Schema/Loader/DBI t/lib
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Tue Nov 24 12:57:26 GMT 2009
Author: caelum
Date: 2009-11-24 12:57:25 +0000 (Tue, 24 Nov 2009)
New Revision: 7948
Modified:
branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader.pm
branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm
branches/DBIx-Class-Schema-Loader/current/t/lib/dbixcsl_mssql_extra_tests.pm
Log:
fix MSSQL default detection to work with numeric/integer columns
Modified: branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm 2009-11-24 09:39:52 UTC (rev 7947)
+++ branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm 2009-11-24 12:57:25 UTC (rev 7948)
@@ -143,9 +143,10 @@
# strip parens
$default =~ s/^\( (.*) \)\z/$1/x;
- # literal or function?
+ # Literal strings are in ''s, numbers are in ()s, everything else is a
+ # function.
$extra_info{default_value} =
- $default =~ /^' (.*) '\z/x ? $1 : \$default;
+ $default =~ /^['(] (.*) [)']\z/x ? $1 : \$default;
}
return \%extra_info;
Modified: branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader.pm 2009-11-24 09:39:52 UTC (rev 7947)
+++ branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader.pm 2009-11-24 12:57:25 UTC (rev 7948)
@@ -416,6 +416,8 @@
Robert Bohne <rbo at openserv.org>
+ribasushi: Peter Rabbitson <rabbit+dbic at rabbit.us>
+
... and lots of other folks. If we forgot you, please write the current
maintainer or RT.
Modified: branches/DBIx-Class-Schema-Loader/current/t/lib/dbixcsl_mssql_extra_tests.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/t/lib/dbixcsl_mssql_extra_tests.pm 2009-11-24 09:39:52 UTC (rev 7947)
+++ branches/DBIx-Class-Schema-Loader/current/t/lib/dbixcsl_mssql_extra_tests.pm 2009-11-24 12:57:25 UTC (rev 7948)
@@ -21,12 +21,14 @@
CREATE TABLE ${vendor}_loader_test2 (
id INT IDENTITY NOT NULL PRIMARY KEY,
dat VARCHAR(100) DEFAULT 'foo',
+ num NUMERIC DEFAULT 10.89,
+ anint INT DEFAULT 6,
ts DATETIME DEFAULT getdate()
)
},
],
drop => [ "[${vendor}_loader_test1.dot]", "${vendor}_loader_test2" ],
- count => 11,
+ count => 13,
run => sub {
my ($schema, $monikers, $classes) = @_;
@@ -53,8 +55,15 @@
my $rsrc = $rs->result_source;
is eval { $rsrc->column_info('dat')->{default_value} }, 'foo',
- 'correct default_value for column with literal default';
+ 'correct default_value for column with literal string default';
+ is eval { $rsrc->column_info('anint')->{default_value} }, 6,
+ 'correct default_value for column with literal integer default';
+
+ cmp_ok eval { $rsrc->column_info('num')->{default_value} },
+ '==', 10.89,
+ 'correct default_value for column with literal numeric default';
+
ok((my $function_default =
eval { $rsrc->column_info('ts')->{default_value} }),
'got default_value for column with function default');
More information about the Bast-commits
mailing list