auto-disambiguate monikers from different schemas
Rafael Kitover [Thu, 17 Nov 2011 21:03:06 +0000 (16:03 -0500)]
Automatically prefix schema and/or database to clashing monikers for the
same table name from different schemas/databases.

Update docs to reflect this behavior.

Also rewrite all the multischema tests to use this new feature instead
of explicit moniker_parts.

Changes
lib/DBIx/Class/Schema/Loader/Base.pm
t/10_02mysql_common.t
t/10_03pg_common.t
t/10_04db2_common.t
t/10_05ora_common.t
t/10_06sybase_common.t
t/10_07mssql_common.t
t/10_08sqlanywhere_common.t
t/10_10informix_common.t

diff --git a/Changes b/Changes
index c49abe5..ebb5b55 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 Revision history for Perl extension DBIx::Class::Schema::Loader
 
+        - automatically prefix database/schema to clashing monikers for
+          the same table name in multischema configurations
+
 0.07012  2011-11-09 15:16:29
         - as of 0.07011 all callbacks receive a ::Loader::Table or
           interface-compatible object instead of the table name, this object
index a5fb775..9d5292a 100644 (file)
@@ -24,7 +24,7 @@ use DBIx::Class::Schema::Loader::Optional::Dependencies ();
 use Try::Tiny;
 use DBIx::Class ();
 use Encode qw/encode decode/;
-use List::MoreUtils qw/all firstidx/;
+use List::MoreUtils qw/all any firstidx uniq/;
 use File::Temp 'tempfile';
 use namespace::clean;
 
@@ -415,8 +415,12 @@ keys and arrays of owners as values, set to the value:
 
 for all owners in all databases.
 
-You may need to control naming of monikers with L</moniker_parts> if you have
-name clashes for tables in different schemas/databases.
+Name clashes resulting from the same table name in different databases/schemas
+will be resolved automatically by prefixing the moniker with the database
+and/or schema.
+
+To prefix/suffix all monikers with the database and/or schema, see
+L</moniker_parts>.
 
 =head2 moniker_parts
 
@@ -1471,39 +1475,92 @@ sub _relbuilder {
 sub _load_tables {
     my ($self, @tables) = @_;
 
-    # Save the new tables to the tables list
+    # Save the new tables to the tables list and compute monikers
     foreach (@tables) {
-        $self->_tables->{$_->sql_name} = $_;
+        $self->_tables->{$_->sql_name}  = $_;
+        $self->monikers->{$_->sql_name} = $self->_table2moniker($_);
     }
 
-    $self->_make_src_class($_) for @tables;
-
-    # sanity-check for moniker clashes
+    # check for moniker clashes
     my $inverse_moniker_idx;
     foreach my $table (values %{ $self->_tables }) {
-      push @{ $inverse_moniker_idx->{$self->monikers->{$table->sql_name}} }, $table;
+        push @{ $inverse_moniker_idx->{$self->monikers->{$table->sql_name}} }, $table;
     }
 
     my @clashes;
     foreach my $moniker (keys %$inverse_moniker_idx) {
-      my $tables = $inverse_moniker_idx->{$moniker};
-      if (@$tables > 1) {
-        push @clashes, sprintf ("tables %s reduced to the same source moniker '%s'",
-          join (', ', map $_->sql_name, @$tables),
-          $moniker,
-        );
-      }
+        my $tables = $inverse_moniker_idx->{$moniker};
+        if (@$tables > 1) {
+            my $different_databases =
+                $tables->[0]->can('database') && (uniq map $_->database||'', @$tables) > 1;
+
+            my $different_schemas =
+                (uniq map $_->schema||'', @$tables) > 1;
+
+            if ($different_databases || $different_schemas) {
+                my ($use_schema, $use_database) = (1, 0);
+
+                if ($different_databases) {
+                    $use_database = 1;
+
+                    # If any monikers are in the same database, we have to distinguish by
+                    # both schema and database.
+                    my %db_counts;
+                    $db_counts{$_}++ for map $_->database, @$tables;
+                    $use_schema = any { $_ > 1 } values %db_counts;
+                }
+
+                delete $self->monikers->{$_->sql_name} for @$tables;
+
+                my $moniker_parts = $self->{moniker_parts};
+
+                my $have_schema   = 1 if any { $_ eq 'schema'   } @{ $self->moniker_parts };
+                my $have_database = 1 if any { $_ eq 'database' } @{ $self->moniker_parts };
+
+                unshift @$moniker_parts, 'schema'   if $use_schema   && !$have_schema;
+                unshift @$moniker_parts, 'database' if $use_database && !$have_database;
+
+                local $self->{moniker_parts} = $moniker_parts;
+
+                my %new_monikers;
+
+                $new_monikers{$_->sql_name} = $self->_table2moniker($_) for @$tables;
+
+                $self->monikers->{$_} = $new_monikers{$_} for map $_->sql_name, @$tables;
+
+                # check if there are still clashes
+                my %by_moniker;
+                
+                while (my ($t, $m) = each %new_monikers) {
+                    push @{ $by_moniker{$m} }, $t; 
+                }
+
+                foreach my $m (grep @{ $by_moniker{$_} } > 1, keys %by_moniker) {
+                    push @clashes, sprintf ("tried disambiguating by moniker_parts, but tables %s still reduced to the same source moniker '%s'",
+                        join (', ', @{ $by_moniker{$m} }),
+                        $m,
+                    );
+                }
+            }
+            else {
+                push @clashes, sprintf ("tables %s reduced to the same source moniker '%s'",
+                    join (', ', map $_->sql_name, @$tables),
+                    $moniker,
+                );
+            }
+        }
     }
 
     if (@clashes) {
-      die   'Unable to load schema - chosen moniker/class naming style results in moniker clashes. '
-          . 'In multi db_schema configurations you may need to set moniker_parts, '
-          . 'otherwise change the naming style, or supply an explicit moniker_map: '
-          . join ('; ', @clashes)
-          . "\n"
-      ;
+        die 'Unable to load schema - chosen moniker/class naming style results in moniker clashes. '
+        . 'Change the naming style, or supply an explicit moniker_map: '
+        . join ('; ', @clashes)
+        . "\n"
+        ;
     }
 
+    $self->_make_src_class($_) for @tables;
+
     $self->_setup_src_meta($_) for @tables;
 
     if(!$self->skip_relationships) {
@@ -2040,7 +2097,7 @@ sub _make_src_class {
     my $schema       = $self->schema;
     my $schema_class = $self->schema_class;
 
-    my $table_moniker = $self->_table2moniker($table);
+    my $table_moniker = $self->monikers->{$table->sql_name};
     my @result_namespace = ($schema_class);
     if ($self->use_namespaces) {
         my $result_namespace = $self->result_namespace || 'Result';
@@ -2085,7 +2142,6 @@ sub _make_src_class {
     }
 
     $self->classes->{$table->sql_name}  = $table_class;
-    $self->monikers->{$table->sql_name} = $table_moniker;
     $self->moniker_to_table->{$table_moniker} = $table;
     $self->class_to_table->{$table_class} = $table;
 
index bc457cd..67af3ee 100644 (file)
@@ -219,6 +219,7 @@ my $tester = dbixcsl_common_tests->new(
                     $dbh->do('CREATE DATABASE `dbicsl-test`');
                 }
                 catch {
+                    diag "CREATE DATABASE returned error: '$_'";
                     skip "no CREATE DATABASE privileges", 30 * 2;
                 };
 
@@ -319,7 +320,6 @@ EOF
                             {
                                 naming => 'current',
                                 db_schema => $db_schema,
-                                moniker_parts => ['schema', 'name'],
                                 dump_directory => EXTRA_DUMP_DIR,
                                 quiet => 1,
                             },
@@ -338,7 +338,7 @@ EOF
                     } 'connected test schema';
 
                     lives_and {
-                        ok $rsrc = $test_schema->source('DbicslDashTestMysqlLoaderTest4');
+                        ok $rsrc = $test_schema->source('MysqlLoaderTest4');
                     } 'got source for table in database name with dash';
 
                     is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
@@ -351,7 +351,7 @@ EOF
                         'column in database name with dash';
 
                     lives_and {
-                        ok $rs = $test_schema->resultset('DbicslDashTestMysqlLoaderTest4');
+                        ok $rs = $test_schema->resultset('MysqlLoaderTest4');
                     } 'got resultset for table in database name with dash';
 
                     lives_and {
@@ -389,7 +389,7 @@ EOF
                         'unique constraint is correct in database name with dash');
 
                     lives_and {
-                        ok $rsrc = $test_schema->source('DbicslDotTestMysqlLoaderTest6');
+                        ok $rsrc = $test_schema->source('MysqlLoaderTest6');
                     } 'got source for table in database name with dot';
 
                     is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
@@ -402,7 +402,7 @@ EOF
                         'column in database name with dot introspected correctly';
 
                     lives_and {
-                        ok $rs = $test_schema->resultset('DbicslDotTestMysqlLoaderTest6');
+                        ok $rs = $test_schema->resultset('MysqlLoaderTest6');
                     } 'got resultset for table in database name with dot';
 
                     lives_and {
@@ -426,7 +426,7 @@ EOF
                     }
 
                     lives_and {
-                        ok $rsrc = $test_schema->source('DbicslDotTestMysqlLoaderTest7');
+                        ok $rsrc = $test_schema->source('MysqlLoaderTest7');
                     } 'got source for table in database name with dot';
 
                     %uniqs = try { $rsrc->unique_constraints };
@@ -443,22 +443,22 @@ EOF
                         skip 'set the environment variable DBICTEST_MYSQL_INNODB=1 to test relationships', 4 unless $test_innodb;
 
                         lives_and {
-                            ok $test_schema->source('DbicslDotTestMysqlLoaderTest6')
+                            ok $test_schema->source('MysqlLoaderTest6')
                                 ->has_relationship('mysql_loader_test4');
                         } 'cross-database relationship in multi-db_schema';
 
                         lives_and {
-                            ok $test_schema->source('DbicslDashTestMysqlLoaderTest4')
+                            ok $test_schema->source('MysqlLoaderTest4')
                                 ->has_relationship('mysql_loader_test6s');
                         } 'cross-database relationship in multi-db_schema';
 
                         lives_and {
-                            ok $test_schema->source('DbicslDashTestMysqlLoaderTest8')
+                            ok $test_schema->source('MysqlLoaderTest8')
                                 ->has_relationship('mysql_loader_test7');
                         } 'cross-database relationship in multi-db_schema';
 
                         lives_and {
-                            ok $test_schema->source('DbicslDotTestMysqlLoaderTest7')
+                            ok $test_schema->source('MysqlLoaderTest7')
                                 ->has_relationship('mysql_loader_test8s');
                         } 'cross-database relationship in multi-db_schema';
                     }
index 8d17f1d..4c9614b 100644 (file)
@@ -275,7 +275,6 @@ my $tester = dbixcsl_common_tests->new(
                         {
                             naming => 'current',
                             db_schema => $db_schema,
-                            moniker_parts => [qw/schema name/],
                             preserve_case => 1,
                             dump_directory => EXTRA_DUMP_DIR,
                             quiet => 1,
@@ -299,7 +298,7 @@ my $tester = dbixcsl_common_tests->new(
                 } 'connected test schema';
 
                 lives_and {
-                    ok $rsrc = $test_schema->source('DbicslDashTestPgLoaderTest4');
+                    ok $rsrc = $test_schema->source('PgLoaderTest4');
                 } 'got source for table in schema name with dash';
 
                 is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
@@ -312,7 +311,7 @@ my $tester = dbixcsl_common_tests->new(
                     'column in schema name with dash';
 
                 lives_and {
-                    ok $rs = $test_schema->resultset('DbicslDashTestPgLoaderTest4');
+                    ok $rs = $test_schema->resultset('PgLoaderTest4');
                 } 'got resultset for table in schema name with dash';
 
                 lives_and {
@@ -346,7 +345,7 @@ my $tester = dbixcsl_common_tests->new(
                     'unique constraint is correct in schema name with dash');
 
                 lives_and {
-                    ok $rsrc = $test_schema->source('DbicslDotTestPgLoaderTest6');
+                    ok $rsrc = $test_schema->source('PgLoaderTest6');
                 } 'got source for table in schema name with dot';
 
                 is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
@@ -359,7 +358,7 @@ my $tester = dbixcsl_common_tests->new(
                     'column in schema name with dot introspected correctly';
 
                 lives_and {
-                    ok $rs = $test_schema->resultset('DbicslDotTestPgLoaderTest6');
+                    ok $rs = $test_schema->resultset('PgLoaderTest6');
                 } 'got resultset for table in schema name with dot';
 
                 lives_and {
@@ -379,7 +378,7 @@ my $tester = dbixcsl_common_tests->new(
                     'relationship in schema name with dot';
 
                 lives_and {
-                    ok $rsrc = $test_schema->source('DbicslDotTestPgLoaderTest7');
+                    ok $rsrc = $test_schema->source('PgLoaderTest7');
                 } 'got source for table in schema name with dot';
 
                 %uniqs = try { $rsrc->unique_constraints };
@@ -393,22 +392,22 @@ my $tester = dbixcsl_common_tests->new(
                     'unique constraint is correct in schema name with dot');
 
                 lives_and {
-                    ok $test_schema->source('DbicslDotTestPgLoaderTest6')
+                    ok $test_schema->source('PgLoaderTest6')
                         ->has_relationship('pg_loader_test4');
                 } 'cross-schema relationship in multi-db_schema';
 
                 lives_and {
-                    ok $test_schema->source('DbicslDashTestPgLoaderTest4')
+                    ok $test_schema->source('PgLoaderTest4')
                         ->has_relationship('pg_loader_test6s');
                 } 'cross-schema relationship in multi-db_schema';
 
                 lives_and {
-                    ok $test_schema->source('DbicslDashTestPgLoaderTest8')
+                    ok $test_schema->source('PgLoaderTest8')
                         ->has_relationship('pg_loader_test7');
                 } 'cross-schema relationship in multi-db_schema';
 
                 lives_and {
-                    ok $test_schema->source('DbicslDotTestPgLoaderTest7')
+                    ok $test_schema->source('PgLoaderTest7')
                         ->has_relationship('pg_loader_test8s');
                 } 'cross-schema relationship in multi-db_schema';
             }
index b86ca49..30f1257 100644 (file)
@@ -185,7 +185,6 @@ EOF
                             {
                                 naming => 'current',
                                 db_schema => $db_schema,
-                                moniker_parts => [qw/schema name/],
                                 dump_directory => EXTRA_DUMP_DIR,
                                 quiet => 1,
                             },
@@ -204,7 +203,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 +216,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 +250,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 +263,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 +283,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 +297,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';
                 }
index 463c968..d274b48 100644 (file)
@@ -276,12 +276,8 @@ EOF
                 my $schema2_moniker = join '', map ucfirst lc, split_name to_identifier $schema2;
 
                 my %monikers;
-                $monikers{'1.4'} = $schema1_moniker . 'OracleLoaderTest4';
                 $monikers{'1.5'} = $schema1_moniker . 'OracleLoaderTest5';
                 $monikers{'2.5'} = $schema2_moniker . 'OracleLoaderTest5';
-                $monikers{'2.6'} = $schema2_moniker . 'OracleLoaderTest6';
-                $monikers{'2.7'} = $schema2_moniker . 'OracleLoaderTest7';
-                $monikers{'1.8'} = $schema1_moniker . 'OracleLoaderTest8';
 
                 foreach my $db_schema ([$schema1, $schema2], '%') {
                     lives_and {
@@ -297,7 +293,6 @@ EOF
                             {
                                 naming => 'current',
                                 db_schema => $db_schema,
-                                moniker_parts => [qw/schema name/],
                                 dump_directory => EXTRA_DUMP_DIR,
                                 quiet => 1,
                             },
@@ -316,7 +311,7 @@ EOF
                     } 'connected test schema';
 
                     lives_and {
-                        ok $rsrc = $test_schema->source($monikers{'1.4'});
+                        ok $rsrc = $test_schema->source('OracleLoaderTest4');
                     } 'got source for table in schema1';
 
                     is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
@@ -329,7 +324,7 @@ EOF
                         'column in schema1';
 
                     lives_and {
-                        ok $rs = $test_schema->resultset($monikers{'1.4'});
+                        ok $rs = $test_schema->resultset('OracleLoaderTest4');
                     } 'got resultset for table in schema1';
 
                     lives_and {
@@ -367,7 +362,7 @@ EOF
                         'correct unique constraint in schema1');
 
                     lives_and {
-                        ok $rsrc = $test_schema->source($monikers{'2.6'});
+                        ok $rsrc = $test_schema->source('OracleLoaderTest6');
                     } 'got source for table in schema2';
 
                     is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
@@ -380,7 +375,7 @@ EOF
                         'column in schema2 introspected correctly';
 
                     lives_and {
-                        ok $rs = $test_schema->resultset($monikers{'2.6'});
+                        ok $rs = $test_schema->resultset('OracleLoaderTest6');
                     } 'got resultset for table in schema2';
 
                     lives_and {
@@ -400,7 +395,7 @@ EOF
                         'relationship in schema2';
 
                     lives_and {
-                        ok $rsrc = $test_schema->source($monikers{'2.7'});
+                        ok $rsrc = $test_schema->source('OracleLoaderTest7');
                     } 'got source for table in schema2';
 
                     %uniqs = try { $rsrc->unique_constraints };
@@ -414,22 +409,22 @@ EOF
                         'correct unique constraint in schema2');
 
                     lives_and {
-                        ok $test_schema->source($monikers{'2.6'})
+                        ok $test_schema->source('OracleLoaderTest6')
                             ->has_relationship('oracle_loader_test4');
                     } 'cross-schema relationship in multi-db_schema';
 
                     lives_and {
-                        ok $test_schema->source($monikers{'1.4'})
+                        ok $test_schema->source('OracleLoaderTest4')
                             ->has_relationship('oracle_loader_test6s');
                     } 'cross-schema relationship in multi-db_schema';
 
                     lives_and {
-                        ok $test_schema->source($monikers{'1.8'})
+                        ok $test_schema->source('OracleLoaderTest8')
                             ->has_relationship('oracle_loader_test7');
                     } 'cross-schema relationship in multi-db_schema';
 
                     lives_and {
-                        ok $test_schema->source($monikers{'2.7'})
+                        ok $test_schema->source('OracleLoaderTest7')
                             ->has_relationship('oracle_loader_test8s');
                     } 'cross-schema relationship in multi-db_schema';
                 }
index f5f7868..afce0d0 100644 (file)
@@ -19,6 +19,8 @@ my $dsn      = $ENV{DBICTEST_SYBASE_DSN} || '';
 my $user     = $ENV{DBICTEST_SYBASE_USER} || '';
 my $password = $ENV{DBICTEST_SYBASE_PASS} || '';
 
+BEGIN { $ENV{DBIC_SYBASE_FREETDS_NOWARN} = 1 }
+
 my ($schema, $databases_created); # for cleanup in END for extra tests
 
 my $tester = dbixcsl_common_tests->new(
@@ -253,7 +255,6 @@ EOF
                                 {
                                     naming => 'current',
                                     db_schema => $db_schema,
-                                    moniker_parts => [qw/database name/],
                                     dump_directory => EXTRA_DUMP_DIR,
                                     quiet => 1,
                                 },
@@ -272,7 +273,7 @@ EOF
                         } 'connected test schema';
 
                         lives_and {
-                            ok $rsrc = $test_schema->source('DbicslTest1SybaseLoaderTest4');
+                            ok $rsrc = $test_schema->source('SybaseLoaderTest4');
                         } 'got source for table in database one';
 
                         is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
@@ -285,7 +286,7 @@ EOF
                             'column in database one';
 
                         lives_and {
-                            ok $rs = $test_schema->resultset('DbicslTest1SybaseLoaderTest4');
+                            ok $rs = $test_schema->resultset('SybaseLoaderTest4');
                         } 'got resultset for table in database one';
 
                         lives_and {
@@ -319,7 +320,7 @@ EOF
                             'correct unique constraint in database one');
 
                         lives_and {
-                            ok $rsrc = $test_schema->source('DbicslTest2SybaseLoaderTest6');
+                            ok $rsrc = $test_schema->source('SybaseLoaderTest6');
                         } 'got source for table in database two';
 
                         is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
@@ -332,7 +333,7 @@ EOF
                             'column in database two introspected correctly';
 
                         lives_and {
-                            ok $rs = $test_schema->resultset('DbicslTest2SybaseLoaderTest6');
+                            ok $rs = $test_schema->resultset('SybaseLoaderTest6');
                         } 'got resultset for table in database two';
 
                         lives_and {
@@ -352,7 +353,7 @@ EOF
                             'relationship in database two';
 
                         lives_and {
-                            ok $rsrc = $test_schema->source('DbicslTest2SybaseLoaderTest7');
+                            ok $rsrc = $test_schema->source('SybaseLoaderTest7');
                         } 'got source for table in database two';
 
                         %uniqs = try { $rsrc->unique_constraints };
@@ -366,22 +367,22 @@ EOF
                             'correct unique constraint in database two');
 
                         lives_and {
-                            ok $test_schema->source('DbicslTest2SybaseLoaderTest6')
+                            ok $test_schema->source('SybaseLoaderTest6')
                                 ->has_relationship('sybase_loader_test4');
                         } 'cross-database relationship in multi database schema';
 
                         lives_and {
-                            ok $test_schema->source('DbicslTest1SybaseLoaderTest4')
+                            ok $test_schema->source('SybaseLoaderTest4')
                                 ->has_relationship('sybase_loader_test6s');
                         } 'cross-database relationship in multi database schema';
 
                         lives_and {
-                            ok $test_schema->source('DbicslTest1SybaseLoaderTest8')
+                            ok $test_schema->source('SybaseLoaderTest8')
                                 ->has_relationship('sybase_loader_test7');
                         } 'cross-database relationship in multi database schema';
 
                         lives_and {
-                            ok $test_schema->source('DbicslTest2SybaseLoaderTest7')
+                            ok $test_schema->source('SybaseLoaderTest7')
                                 ->has_relationship('sybase_loader_test8s');
                         } 'cross-database relationship in multi database schema';
                     }
index 5a31bef..13c57d4 100644 (file)
@@ -362,7 +362,6 @@ EOF
                             {
                                 naming => 'current',
                                 db_schema => $db_schema,
-                                moniker_parts => [qw/schema name/],
                                 dump_directory => EXTRA_DUMP_DIR,
                                 quiet => 1,
                             },
@@ -381,7 +380,7 @@ EOF
                     } 'connected test schema';
 
                     lives_and {
-                        ok $rsrc = $test_schema->source('DbicslDashTestMssqlLoaderTest8');
+                        ok $rsrc = $test_schema->source('MssqlLoaderTest8');
                     } 'got source for table in schema name with dash';
 
                     is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
@@ -394,7 +393,7 @@ EOF
                         'column in schema name with dash';
 
                     lives_and {
-                        ok $rs = $test_schema->resultset('DbicslDashTestMssqlLoaderTest8');
+                        ok $rs = $test_schema->resultset('MssqlLoaderTest8');
                     } 'got resultset for table in schema name with dash';
 
                     lives_and {
@@ -428,7 +427,7 @@ EOF
                         'correct unique constraint in schema name with dash');
 
                     lives_and {
-                        ok $rsrc = $test_schema->source('DbicslDotTestMssqlLoaderTest10');
+                        ok $rsrc = $test_schema->source('MssqlLoaderTest10');
                     } 'got source for table in schema name with dot';
 
                     is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
@@ -441,7 +440,7 @@ EOF
                         'column in schema name with dot introspected correctly';
 
                     lives_and {
-                        ok $rs = $test_schema->resultset('DbicslDotTestMssqlLoaderTest10');
+                        ok $rs = $test_schema->resultset('MssqlLoaderTest10');
                     } 'got resultset for table in schema name with dot';
 
                     lives_and {
@@ -461,7 +460,7 @@ EOF
                         'relationship in schema name with dot';
 
                     lives_and {
-                        ok $rsrc = $test_schema->source('DbicslDotTestMssqlLoaderTest11');
+                        ok $rsrc = $test_schema->source('MssqlLoaderTest11');
                     } 'got source for table in schema name with dot';
 
                     %uniqs = try { $rsrc->unique_constraints };
@@ -475,22 +474,22 @@ EOF
                         'correct unique constraint in schema name with dot');
 
                     lives_and {
-                        ok $test_schema->source('DbicslDotTestMssqlLoaderTest10')
+                        ok $test_schema->source('MssqlLoaderTest10')
                             ->has_relationship('mssql_loader_test8');
                     } 'cross-schema relationship in multi-db_schema';
 
                     lives_and {
-                        ok $test_schema->source('DbicslDashTestMssqlLoaderTest8')
+                        ok $test_schema->source('MssqlLoaderTest8')
                             ->has_relationship('mssql_loader_test10s');
                     } 'cross-schema relationship in multi-db_schema';
 
                     lives_and {
-                        ok $test_schema->source('DbicslDashTestMssqlLoaderTest12')
+                        ok $test_schema->source('MssqlLoaderTest12')
                             ->has_relationship('mssql_loader_test11');
                     } 'cross-schema relationship in multi-db_schema';
 
                     lives_and {
-                        ok $test_schema->source('DbicslDotTestMssqlLoaderTest11')
+                        ok $test_schema->source('MssqlLoaderTest11')
                             ->has_relationship('mssql_loader_test12s');
                     } 'cross-schema relationship in multi-db_schema';
                 }
@@ -510,6 +509,7 @@ EOF
                     $dbh->do('CREATE DATABASE dbicsl_test1');
                 }
                 catch {
+                    diag "no CREATE DATABASE privileges: '$_'";
                     skip "no CREATE DATABASE privileges", 26 * 2;
                 };
 
@@ -571,7 +571,6 @@ EOF
                             {
                                 naming => 'current',
                                 db_schema => $db_schema,
-                                moniker_parts => [qw/database name/],
                                 dump_directory => EXTRA_DUMP_DIR,
                                 quiet => 1,
                             },
@@ -592,7 +591,7 @@ EOF
                     my ($rsrc, $rs, $row, $rel_info, %uniqs);
 
                     lives_and {
-                        ok $rsrc = $test_schema->source('DbicslTest1MssqlLoaderTest13');
+                        ok $rsrc = $test_schema->source('MssqlLoaderTest13');
                     } 'got source for table in database one';
 
                     is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
@@ -605,7 +604,7 @@ EOF
                         'column in database one';
 
                     lives_and {
-                        ok $rs = $test_schema->resultset('DbicslTest1MssqlLoaderTest13');
+                        ok $rs = $test_schema->resultset('MssqlLoaderTest13');
                     } 'got resultset for table in database one';
 
                     lives_and {
@@ -639,7 +638,7 @@ EOF
                         'correct unique constraint in database one');
 
                     lives_and {
-                        ok $rsrc = $test_schema->source('DbicslTest2MssqlLoaderTest15');
+                        ok $rsrc = $test_schema->source('MssqlLoaderTest15');
                     } 'got source for table in database two';
 
                     is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
@@ -652,7 +651,7 @@ EOF
                         'column in database two introspected correctly';
 
                     lives_and {
-                        ok $rs = $test_schema->resultset('DbicslTest2MssqlLoaderTest15');
+                        ok $rs = $test_schema->resultset('MssqlLoaderTest15');
                     } 'got resultset for table in database two';
 
                     lives_and {
@@ -672,7 +671,7 @@ EOF
                         'relationship in database two';
 
                     lives_and {
-                        ok $rsrc = $test_schema->source('DbicslTest2MssqlLoaderTest16');
+                        ok $rsrc = $test_schema->source('MssqlLoaderTest16');
                     } 'got source for table in database two';
 
                     %uniqs = try { $rsrc->unique_constraints };
index d5353f8..a626b86 100644 (file)
@@ -230,7 +230,6 @@ EOF
                             {
                                 naming => 'current',
                                 db_schema => $db_schema,
-                                moniker_parts => [qw/schema name/],
                                 dump_directory => EXTRA_DUMP_DIR,
                                 quiet => 1,
                             },
@@ -249,7 +248,7 @@ EOF
                     } 'connected test schema';
 
                     lives_and {
-                        ok $rsrc = $test_schema->source('DbicslTest1SqlanywhereLoaderTest4');
+                        ok $rsrc = $test_schema->source('SqlanywhereLoaderTest4');
                     } 'got source for table in schema one';
 
                     is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
@@ -262,7 +261,7 @@ EOF
                         'column in schema one';
 
                     lives_and {
-                        ok $rs = $test_schema->resultset('DbicslTest1SqlanywhereLoaderTest4');
+                        ok $rs = $test_schema->resultset('SqlanywhereLoaderTest4');
                     } 'got resultset for table in schema one';
 
                     lives_and {
@@ -296,7 +295,7 @@ EOF
                         'correct unique constraint in schema one');
 
                     lives_and {
-                        ok $rsrc = $test_schema->source('DbicslTest2SqlanywhereLoaderTest6');
+                        ok $rsrc = $test_schema->source('SqlanywhereLoaderTest6');
                     } 'got source for table in schema two';
 
                     is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
@@ -309,7 +308,7 @@ EOF
                         'column in schema two introspected correctly';
 
                     lives_and {
-                        ok $rs = $test_schema->resultset('DbicslTest2SqlanywhereLoaderTest6');
+                        ok $rs = $test_schema->resultset('SqlanywhereLoaderTest6');
                     } 'got resultset for table in schema two';
 
                     lives_and {
@@ -329,7 +328,7 @@ EOF
                         'relationship in schema two';
 
                     lives_and {
-                        ok $rsrc = $test_schema->source('DbicslTest2SqlanywhereLoaderTest7');
+                        ok $rsrc = $test_schema->source('SqlanywhereLoaderTest7');
                     } 'got source for table in schema two';
 
                     %uniqs = try { $rsrc->unique_constraints };
@@ -343,22 +342,22 @@ EOF
                         'correct unique constraint in schema two');
 
                     lives_and {
-                        ok $test_schema->source('DbicslTest2SqlanywhereLoaderTest6')
+                        ok $test_schema->source('SqlanywhereLoaderTest6')
                             ->has_relationship('sqlanywhere_loader_test4');
                     } 'cross-schema relationship in multi-db_schema';
 
                     lives_and {
-                        ok $test_schema->source('DbicslTest1SqlanywhereLoaderTest4')
+                        ok $test_schema->source('SqlanywhereLoaderTest4')
                             ->has_relationship('sqlanywhere_loader_test6s');
                     } 'cross-schema relationship in multi-db_schema';
 
                     lives_and {
-                        ok $test_schema->source('DbicslTest1SqlanywhereLoaderTest8')
+                        ok $test_schema->source('SqlanywhereLoaderTest8')
                             ->has_relationship('sqlanywhere_loader_test7');
                     } 'cross-schema relationship in multi-db_schema';
 
                     lives_and {
-                        ok $test_schema->source('DbicslTest2SqlanywhereLoaderTest7')
+                        ok $test_schema->source('SqlanywhereLoaderTest7')
                             ->has_relationship('sqlanywhere_loader_test8s');
                     } 'cross-schema relationship in multi-db_schema';
                 }
index 00832c3..e2f77c9 100644 (file)
@@ -205,7 +205,6 @@ EOF
                             {
                                 naming => 'current',
                                 db_schema => $db_schema,
-                                moniker_parts => [qw/database name/],
                                 dump_directory => EXTRA_DUMP_DIR,
                                 quiet => 1,
                             },
@@ -226,7 +225,7 @@ EOF
                     my ($rsrc, $rs, $row, $rel_info, %uniqs);
 
                     lives_and {
-                        ok $rsrc = $test_schema->source("${db1_moniker}InformixLoaderTest4");
+                        ok $rsrc = $test_schema->source("InformixLoaderTest4");
                     } 'got source for table in database one';
 
                     is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
@@ -239,7 +238,7 @@ EOF
                         'column in database one';
 
                     lives_and {
-                        ok $rs = $test_schema->resultset("${db1_moniker}InformixLoaderTest4");
+                        ok $rs = $test_schema->resultset("InformixLoaderTest4");
                     } 'got resultset for table in database one';
 
                     lives_and {
@@ -273,7 +272,7 @@ EOF
                         'correct unique constraint in database one');
 
                     lives_and {
-                        ok $rsrc = $test_schema->source("${db2_moniker}InformixLoaderTest6");
+                        ok $rsrc = $test_schema->source("InformixLoaderTest6");
                     } 'got source for table in database two';
 
                     is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
@@ -286,7 +285,7 @@ EOF
                         'column in database two introspected correctly';
 
                     lives_and {
-                        ok $rs = $test_schema->resultset("${db2_moniker}InformixLoaderTest6");
+                        ok $rs = $test_schema->resultset("InformixLoaderTest6");
                     } 'got resultset for table in database two';
 
                     lives_and {
@@ -306,7 +305,7 @@ EOF
                         'relationship in database two';
 
                     lives_and {
-                        ok $rsrc = $test_schema->source("${db2_moniker}InformixLoaderTest7");
+                        ok $rsrc = $test_schema->source("InformixLoaderTest7");
                     } 'got source for table in database two';
 
                     %uniqs = try { $rsrc->unique_constraints };