work around ORA-24345 from $dbh->column_info
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 10_03pg_common.t
index eb845a7..4c9614b 100644 (file)
@@ -190,13 +190,22 @@ my $tester = dbixcsl_common_tests->new(
                 CREATE TABLE "dbicsl-test".pg_loader_test5 (
                     id SERIAL PRIMARY KEY,
                     value VARCHAR(100),
-                    four_id INTEGER UNIQUE REFERENCES "dbicsl-test".pg_loader_test4 (id)
+                    four_id INTEGER REFERENCES "dbicsl-test".pg_loader_test4 (id),
+                    CONSTRAINT loader_test5_uniq UNIQUE (four_id)
                 )
             },
             q{
                 CREATE SCHEMA "dbicsl.test"
             },
             q{
+                CREATE TABLE "dbicsl.test".pg_loader_test5 (
+                    pk SERIAL PRIMARY KEY,
+                    value VARCHAR(100),
+                    four_id INTEGER REFERENCES "dbicsl-test".pg_loader_test4 (id),
+                    CONSTRAINT loader_test5_uniq UNIQUE (four_id)
+                )
+            },
+            q{
                 CREATE TABLE "dbicsl.test".pg_loader_test6 (
                     id SERIAL PRIMARY KEY,
                     value VARCHAR(100),
@@ -225,7 +234,7 @@ my $tester = dbixcsl_common_tests->new(
             'DROP TYPE pg_loader_test_enum',
         ],
         drop  => [ qw/ pg_loader_test1 pg_loader_test2 / ],
-        count => 4 + 28 * 2,
+        count => 4 + 30 * 2,
         run   => sub {
             my ($schema, $monikers, $classes) = @_;
 
@@ -309,7 +318,7 @@ my $tester = dbixcsl_common_tests->new(
                     ok $row = $rs->create({ value => 'foo' });
                 } 'executed SQL on table in schema name with dash';
 
-                $rel_info = try { $rsrc->relationship_info('pg_loader_test5') };
+                $rel_info = try { $rsrc->relationship_info('dbicsl_dash_test_pg_loader_test5') };
 
                 is_deeply $rel_info->{cond}, {
                     'foreign.four_id' => 'self.id'
@@ -322,7 +331,7 @@ my $tester = dbixcsl_common_tests->new(
                     'relationship in schema name with dash';
 
                 lives_and {
-                    ok $rsrc = $test_schema->source('PgLoaderTest5');
+                    ok $rsrc = $test_schema->source('DbicslDashTestPgLoaderTest5');
                 } 'got source for table in schema name with dash';
 
                 %uniqs = try { $rsrc->unique_constraints };
@@ -330,6 +339,11 @@ my $tester = dbixcsl_common_tests->new(
                 is keys %uniqs, 2,
                     'got unique and primary constraint in schema name with dash';
 
+                delete $uniqs{primary};
+
+                is_deeply ((values %uniqs)[0], ['four_id'],
+                    'unique constraint is correct in schema name with dash');
+
                 lives_and {
                     ok $rsrc = $test_schema->source('PgLoaderTest6');
                 } 'got source for table in schema name with dot';
@@ -372,6 +386,11 @@ my $tester = dbixcsl_common_tests->new(
                 is keys %uniqs, 2,
                     'got unique and primary constraint in schema name with dot';
 
+                delete $uniqs{primary};
+
+                is_deeply ((values %uniqs)[0], ['six_id'],
+                    'unique constraint is correct in schema name with dot');
+
                 lives_and {
                     ok $test_schema->source('PgLoaderTest6')
                         ->has_relationship('pg_loader_test4');