Fix detection of qualified sequence names for Oracle (RT#90341)
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 10_04db2_common.t
index b86ca49..e0804b8 100644 (file)
@@ -46,6 +46,8 @@ my $tester = dbixcsl_common_tests->new(
     null           => '',
     preserve_case_mode_is_exclusive => 1,
     quote_char                      => '"',
+    default_is_deferrable => 1,
+    default_on_clause => 'NO ACTION',
     data_types => {
         # http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/admin/r0008483.htm
         #
@@ -104,11 +106,41 @@ my $tester = dbixcsl_common_tests->new(
 #        datalink           => { data_type => 'datalink' },
     },
     extra => {
-        count => 30 * 2,
+        create => [
+            # 4 through 8 are used for the multi-schema tests
+            q{
+                create table db2_loader_test9 (
+                    id int generated by default as identity not null primary key
+                )
+            },
+            q{
+                create table db2_loader_test10 (
+                    id int generated by default as identity not null primary key,
+                    nine_id int,
+                    foreign key (nine_id) references db2_loader_test9(id)
+                        on delete set null on update restrict
+                )
+            },
+        ],
+        drop  => [ qw/db2_loader_test9 db2_loader_test10/ ],
+        count => 4 + 30 * 2,
         run => sub {
-            SKIP: {
-                $schema = shift;
+            $schema = shift;
+
+            # test on delete/update fk clause introspection
+            ok ((my $rel_info = $schema->source('Db2LoaderTest10')->relationship_info('nine')),
+                'got rel info');
+
+            is $rel_info->{attrs}{on_delete}, 'SET NULL',
+                'ON DELETE clause introspected correctly';
 
+            is $rel_info->{attrs}{on_update}, 'RESTRICT',
+                'ON UPDATE clause introspected correctly';
+
+            is $rel_info->{attrs}{is_deferrable}, 1,
+                'DEFERRABLE defaults to 1';
+
+            SKIP: {
                 my $dbh = $schema->storage->dbh;
 
                 try {
@@ -185,7 +217,6 @@ EOF
                             {
                                 naming => 'current',
                                 db_schema => $db_schema,
-                                moniker_parts => [qw/schema name/],
                                 dump_directory => EXTRA_DUMP_DIR,
                                 quiet => 1,
                             },
@@ -204,7 +235,7 @@ EOF
                     } 'connected test schema';
 
                     lives_and {
-                        ok $rsrc = $test_schema->source('DbicslDashTestDb2LoaderTest4');
+                        ok $rsrc = $test_schema->source('Db2LoaderTest4');
                     } 'got source for table in schema name with dash';
 
                     is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
@@ -217,7 +248,7 @@ EOF
                         'column in schema name with dash';
 
                     lives_and {
-                        ok $rs = $test_schema->resultset('DbicslDashTestDb2LoaderTest4');
+                        ok $rs = $test_schema->resultset('Db2LoaderTest4');
                     } 'got resultset for table in schema name with dash';
 
                     lives_and {
@@ -251,7 +282,7 @@ EOF
                         'correct unique constraint in schema name with dash');
 
                     lives_and {
-                        ok $rsrc = $test_schema->source('DbicslDotTestDb2LoaderTest6');
+                        ok $rsrc = $test_schema->source('Db2LoaderTest6');
                     } 'got source for table in schema name with dot';
 
                     is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
@@ -264,7 +295,7 @@ EOF
                         'column in schema name with dot introspected correctly';
 
                     lives_and {
-                        ok $rs = $test_schema->resultset('DbicslDotTestDb2LoaderTest6');
+                        ok $rs = $test_schema->resultset('Db2LoaderTest6');
                     } 'got resultset for table in schema name with dot';
 
                     lives_and {
@@ -284,7 +315,7 @@ EOF
                         'relationship in schema name with dot';
 
                     lives_and {
-                        ok $rsrc = $test_schema->source('DbicslDotTestDb2LoaderTest7');
+                        ok $rsrc = $test_schema->source('Db2LoaderTest7');
                     } 'got source for table in schema name with dot';
 
                     %uniqs = try { $rsrc->unique_constraints };
@@ -298,22 +329,22 @@ EOF
                         'correct unique constraint in schema name with dot');
 
                     lives_and {
-                        ok $test_schema->source('DbicslDotTestDb2LoaderTest6')
+                        ok $test_schema->source('Db2LoaderTest6')
                             ->has_relationship('db2_loader_test4');
                     } 'cross-schema relationship in multi-db_schema';
 
                     lives_and {
-                        ok $test_schema->source('DbicslDashTestDb2LoaderTest4')
+                        ok $test_schema->source('Db2LoaderTest4')
                             ->has_relationship('db2_loader_test6s');
                     } 'cross-schema relationship in multi-db_schema';
 
                     lives_and {
-                        ok $test_schema->source('DbicslDashTestDb2LoaderTest8')
+                        ok $test_schema->source('Db2LoaderTest8')
                             ->has_relationship('db2_loader_test7');
                     } 'cross-schema relationship in multi-db_schema';
 
                     lives_and {
-                        ok $test_schema->source('DbicslDotTestDb2LoaderTest7')
+                        ok $test_schema->source('Db2LoaderTest7')
                             ->has_relationship('db2_loader_test8s');
                     } 'cross-schema relationship in multi-db_schema';
                 }