test for qualified Pg sequence
Rafael Kitover [Mon, 19 Jul 2010 20:48:22 +0000 (16:48 -0400)]
t/12pg_common.t
t/lib/dbixcsl_common_tests.pm

index bb03601..e40cbd6 100644 (file)
@@ -113,8 +113,14 @@ my $tester = dbixcsl_common_tests->new(
     extra       => {
         create => [
             q{
+                CREATE SCHEMA dbicsl_test
+            },
+            q{
+                CREATE SEQUENCE dbicsl_test.myseq
+            },
+            q{
                 CREATE TABLE pg_loader_test1 (
-                    id SERIAL NOT NULL PRIMARY KEY,
+                    id INTEGER NOT NULL DEFAULT nextval('dbicsl_test.myseq') PRIMARY KEY,
                     value VARCHAR(100)
                 )
             },
@@ -134,11 +140,18 @@ my $tester = dbixcsl_common_tests->new(
                 COMMENT ON TABLE pg_loader_test2 IS 'very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long comment'
             },
         ],
+        pre_drop_ddl => [
+            'DROP SCHEMA dbicsl_test CASCADE',
+        ],
         drop  => [ qw/ pg_loader_test1 pg_loader_test2 / ],
-        count => 3,
+        count => 4,
         run   => sub {
             my ($schema, $monikers, $classes) = @_;
 
+            is $schema->source($monikers->{pg_loader_test1})->column_info('id')->{sequence},
+                'dbicsl_test.myseq',
+                'qualified sequence detected';
+
             my $class    = $classes->{pg_loader_test1};
             my $filename = $schema->_loader->_get_dump_filename($class);
 
index 1cb1ce2..22dc59d 100644 (file)
@@ -155,7 +155,12 @@ sub drop_extra_tables_only {
     my $self = shift;
 
     my $dbh = $self->dbconnect(0);
-    $dbh->do($_) for @{ $self->{extra}{pre_drop_ddl} || [] };
+
+    {
+        local $SIG{__WARN__} = sub {}; # postgres notices
+        $dbh->do($_) for @{ $self->{extra}{pre_drop_ddl} || [] };
+    }
+
     $dbh->do("DROP TABLE $_") for @{ $self->{extra}{drop} || [] };
 
     foreach my $data_type_table (@{ $self->{data_type_tests}{table_names} || [] }) {
@@ -1715,7 +1720,11 @@ sub drop_tables {
 
     my $dbh = $self->dbconnect(0);
 
-    $dbh->do($_) for @{ $self->{extra}{pre_drop_ddl} || [] };
+    {
+        local $SIG{__WARN__} = sub {}; # postgres notices
+        $dbh->do($_) for @{ $self->{extra}{pre_drop_ddl} || [] };
+    }
+
     $dbh->do("DROP TABLE $_") for @{ $self->{extra}{drop} || [] };
 
     my $drop_auto_inc = $self->{auto_inc_drop_cb} || sub {};