From: Rafael Kitover Date: Mon, 17 Jan 2011 04:39:27 +0000 (-0500) Subject: add auto_nextval => 1 to uniqueidentifier columns on MSSQL and to uniqueidentifier... X-Git-Tag: 0.07003~12 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e4d9f5156f1e62ab07ec1884c81f4a325584dfd0;p=dbsrgits%2FDBIx-Class-Schema-Loader.git add auto_nextval => 1 to uniqueidentifier columns on MSSQL and to uniqueidentifier and uniqueidentifierstr columns on SQLAnywhere --- diff --git a/Changes b/Changes index 5d656ba..7c0118b 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,7 @@ Revision history for Perl extension DBIx::Class::Schema::Loader + - add auto_nextval => 1 to uniqueidentifier columns on MSSQL and to + uniqueidentifier and uniqueidentifierstr columns on SQLAnywhere - add datetime_undef_if_invalid => 1 for MySQL datetime data types (RT#64820) - added column_accessor_map option diff --git a/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm b/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm index 17e8dd9..4aabd9b 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm @@ -253,6 +253,9 @@ AND table_name = @{[ $dbh->quote($table) ]} AND column_name = @{[ $dbh->quote($c delete $info->{size} if $info->{size} == 7; } + elsif ($info->{data_type} eq 'uniqueidentifier') { + $info->{auto_nextval} = 1; + } if ($info->{data_type} !~ /^(?:n?char|n?varchar|binary|varbinary|numeric|decimal|float|datetime(?:2|offset)|time)\z/) { delete $info->{size}; diff --git a/lib/DBIx/Class/Schema/Loader/DBI/SQLAnywhere.pm b/lib/DBIx/Class/Schema/Loader/DBI/SQLAnywhere.pm index 46e15fe..6fc5769 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/SQLAnywhere.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/SQLAnywhere.pm @@ -102,6 +102,9 @@ EOF elsif ($info->{data_type} eq 'float') { $info->{data_type} = 'real'; } + elsif ($info->{data_type} =~ /^uniqueidentifier(?:str)?\z/) { + $info->{auto_nextval} = 1; + } delete $info->{default_value} if ref($info->{default_value}) eq 'SCALAR' && ${ $info->{default_value} } eq 'NULL'; diff --git a/t/16mssql_common.t b/t/16mssql_common.t index 4ce93a7..cf77ed6 100644 --- a/t/16mssql_common.t +++ b/t/16mssql_common.t @@ -149,7 +149,7 @@ my $tester = dbixcsl_common_tests->new( # other types timestamp => { data_type => 'timestamp', inflate_datetime => 0 }, rowversion => { data_type => 'rowversion' }, - uniqueidentifier => { data_type => 'uniqueidentifier' }, + uniqueidentifier => { data_type => 'uniqueidentifier', auto_nextval => 1 }, sql_variant => { data_type => 'sql_variant' }, xml => { data_type => 'xml' }, }, diff --git a/t/17sqlanywhere_common.t b/t/17sqlanywhere_common.t index 797c542..1a8421f 100644 --- a/t/17sqlanywhere_common.t +++ b/t/17sqlanywhere_common.t @@ -112,7 +112,7 @@ my $tester = dbixcsl_common_tests->new( 'nvarchar(20)' => { data_type => 'nvarchar', size => 20 }, 'xml' => { data_type => 'xml' }, 'uniqueidentifierstr' - => { data_type => 'uniqueidentifierstr' }, + => { data_type => 'uniqueidentifierstr', auto_nextval => 1 }, # Binary types 'binary' => { data_type => 'binary', size => 1 }, @@ -120,7 +120,7 @@ my $tester = dbixcsl_common_tests->new( 'varbinary' => { data_type => 'varbinary', size => 1 }, 'varbinary(20)'=> { data_type => 'varbinary', size => 20 }, 'uniqueidentifier' - => { data_type => 'uniqueidentifier' }, + => { data_type => 'uniqueidentifier', auto_nextval => 1 }, # Blob types 'long binary' => { data_type => 'long binary' },