Subject: | BIGSERIAL / BIGINT in PostgreSQL |
There is a special case for serial -> int4 already, but in PostgreSQL there is also bigserial that match to int8.
Attached a patch with test.
Subject: | Parse-Dia-SQL-0.25.bigserial.patch |
diff -r -u Parse-Dia-SQL-0.25.orig/lib/Parse/Dia/SQL/Utils.pm Parse-Dia-SQL-0.25/lib/Parse/Dia/SQL/Utils.pm
--- Parse-Dia-SQL-0.25.orig/lib/Parse/Dia/SQL/Utils.pm 2012-07-24 09:13:55.000000000 +0200
+++ Parse-Dia-SQL-0.25/lib/Parse/Dia/SQL/Utils.pm 2013-12-09 17:49:17.948002275 +0100
@@ -549,7 +549,7 @@
$self->{log}->info(qq{Replaced $typeName with smallint}) if $self->{log}->is_info();
return 'smallint';
}
- if ( lc($typeName) eq 'int8' ) {
+ if ( lc($typeName) eq 'bigserial' or lc($typeName) eq 'int8' ) {
$self->{log}->info(qq{Replaced $typeName with bigint}) if $self->{log}->is_info();
return 'bigint';
}
diff -r -u Parse-Dia-SQL-0.25.orig/t/703-utils-get-base-name.t Parse-Dia-SQL-0.25/t/703-utils-get-base-name.t
--- Parse-Dia-SQL-0.25.orig/t/703-utils-get-base-name.t 2011-02-15 21:11:10.000000000 +0100
+++ Parse-Dia-SQL-0.25/t/703-utils-get-base-name.t 2013-12-09 17:49:30.300001824 +0100
@@ -8,7 +8,7 @@
use File::Spec::Functions;
use lib catdir qw ( blib lib );
-plan tests => 7;
+plan tests => 8;
use lib q{lib};
use_ok ('Parse::Dia::SQL::Utils');
@@ -22,6 +22,7 @@
is($utils->get_base_type('int4', 'postgres'), 'integer');
is($utils->get_base_type('serial', 'postgres'), 'integer');
is($utils->get_base_type('int8', 'postgres'), 'bigint');
+is($utils->get_base_type('bigserial', 'postgres'), 'bigint');
is($utils->get_base_type('int2', 'mysql-myisam'), 'int2');