Check truth of preserve_case not definedness
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 10_04db2_common.t
index 03b4b54..30f1257 100644 (file)
@@ -104,7 +104,7 @@ my $tester = dbixcsl_common_tests->new(
 #        datalink           => { data_type => 'datalink' },
     },
     extra => {
-        count => 28 * 2,
+        count => 30 * 2,
         run => sub {
             SKIP: {
                 $schema = shift;
@@ -129,12 +129,22 @@ EOF
                     CREATE TABLE "dbicsl-test".db2_loader_test5 (
                         id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL PRIMARY KEY,
                         value VARCHAR(100),
-                        four_id INTEGER NOT NULL UNIQUE,
+                        four_id INTEGER NOT NULL,
+                        CONSTRAINT loader_test5_uniq UNIQUE (four_id),
                         FOREIGN KEY (four_id) REFERENCES "dbicsl-test".db2_loader_test4 (id)
                     )
 EOF
                 $dbh->do('CREATE SCHEMA "dbicsl.test"');
                 $dbh->do(<<"EOF");
+                    CREATE TABLE "dbicsl.test".db2_loader_test5 (
+                        pk INT GENERATED BY DEFAULT AS IDENTITY NOT NULL PRIMARY KEY,
+                        value VARCHAR(100),
+                        four_id INTEGER NOT NULL,
+                        CONSTRAINT loader_test5_uniq UNIQUE (four_id),
+                        FOREIGN KEY (four_id) REFERENCES "dbicsl-test".db2_loader_test4 (id)
+                    )
+EOF
+                $dbh->do(<<"EOF");
                     CREATE TABLE "dbicsl.test".db2_loader_test6 (
                         id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL PRIMARY KEY,
                         value VARCHAR(100),
@@ -213,7 +223,7 @@ EOF
                         ok $row = $rs->create({ value => 'foo' });
                     } 'executed SQL on table in schema name with dash';
 
-                    $rel_info = try { $rsrc->relationship_info('db2_loader_test5') };
+                    $rel_info = try { $rsrc->relationship_info('dbicsl_dash_test_db2_loader_test5') };
 
                     is_deeply $rel_info->{cond}, {
                         'foreign.four_id' => 'self.id'
@@ -226,7 +236,7 @@ EOF
                         'relationship in schema name with dash';
 
                     lives_and {
-                        ok $rsrc = $test_schema->source('Db2LoaderTest5');
+                        ok $rsrc = $test_schema->source('DbicslDashTestDb2LoaderTest5');
                     } 'got source for table in schema name with dash';
 
                     %uniqs = try { $rsrc->unique_constraints };
@@ -234,6 +244,11 @@ EOF
                     is keys %uniqs, 2,
                         'got unique and primary constraint in schema name with dash';
 
+                    delete $uniqs{primary};
+
+                    is_deeply ((values %uniqs)[0], ['four_id'],
+                        'correct unique constraint in schema name with dash');
+
                     lives_and {
                         ok $rsrc = $test_schema->source('Db2LoaderTest6');
                     } 'got source for table in schema name with dot';
@@ -276,6 +291,11 @@ EOF
                     is keys %uniqs, 2,
                         'got unique and primary constraint in schema name with dot';
 
+                    delete $uniqs{primary};
+
+                    is_deeply ((values %uniqs)[0], ['six_id'],
+                        'correct unique constraint in schema name with dot');
+
                     lives_and {
                         ok $test_schema->source('Db2LoaderTest6')
                             ->has_relationship('db2_loader_test4');
@@ -311,6 +331,7 @@ END {
                                '"dbicsl.test".db2_loader_test7',
                                '"dbicsl.test".db2_loader_test6',
                                '"dbicsl-test".db2_loader_test5',
+                               '"dbicsl.test".db2_loader_test5',
                                '"dbicsl-test".db2_loader_test4') {
                 try {
                     $dbh->do("DROP TABLE $table");