From: Dagfinn Ilmari Mannsåker Date: Sun, 27 Jan 2008 09:01:42 +0000 (+0000) Subject: Add support for extra => { unsigned => 1 } for MySQL. X-Git-Tag: 0.04999_01~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8fdd52a2c9120bf37c8969959152822e9312413d;p=dbsrgits%2FDBIx-Class-Schema-Loader.git Add support for extra => { unsigned => 1 } for MySQL. --- diff --git a/Changes b/Changes index 455a4a0..5429fe5 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,7 @@ Revision history for Perl extension DBIx::Class::Schema::Loader 0.04999_01 Not yet released - Add support for vendor-specific extra column attributes. + - Add support for extra => { unsigned => 1 } for MySQL. - Set join_type => 'LEFT OUTER' for nullable foreign keys (patch from Bernhard Weißhuhn) - Set is_auto_increment for auto-increment columns (RT #31473) diff --git a/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm b/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm index 219f06b..a4f795a 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm @@ -127,6 +127,17 @@ sub _column_is_auto_increment { return $info->{mysql_is_auto_increment}; } +sub _column_extra_attr { + my ($self, $info) = @_; + + my $extra_attr; + if ($info->{mysql_type_name} =~ /\bunsigned\b/i) { + $extra_attr->{unsigned} = 1; + } + + return $extra_attr; +} + =head1 SEE ALSO L, L, diff --git a/t/11mysql_common.t b/t/11mysql_common.t index c65c7b1..26575b8 100644 --- a/t/11mysql_common.t +++ b/t/11mysql_common.t @@ -1,6 +1,7 @@ use strict; use lib qw(t/lib); use dbixcsl_common_tests; +use Test::More; my $dsn = $ENV{DBICTEST_MYSQL_DSN} || ''; my $user = $ENV{DBICTEST_MYSQL_USER} || ''; @@ -19,6 +20,25 @@ my $tester = dbixcsl_common_tests->new( skip_rels => $test_innodb ? 0 : $skip_rels_msg, no_inline_rels => 1, no_implicit_rels => 1, + extra => { + create => [ + qq{ + CREATE TABLE mysql_loader_test1 ( + id INTEGER UNSIGNED NOT NULL PRIMARY KEY + ) + }, + ], + drop => [ qw/ mysql_loader_test1 / ], + count => 1, + run => sub { + my ($schema, $monikers, $classes) = @_; + + my $rs = $schema->resultset($monikers->{mysql_loader_test1}); + my $column_info = $rs->result_source->column_info('id'); + + is($column_info->{extra}->{unsigned}, 1, 'Unsigned MySQL columns'); + }, + } ); if( !$dsn || !$user ) {