- $schema->loader is now a public method
- add schema_components option
- sort relationships so they always come out in the same order
+ - also sort unique constraints so they always come out in the same order
- multi db_schema support with cross-schema rels (RT#39478)
- added moniker_parts option for name clashes in multi db_schema setups
- add quiet option
- make 23dumpmore.t auto cleanup and remove dump warnings
- generate POD for schema class with class list
- remove implicit rels from common tests so all tests work on MySQL
- - sort unique keys by name
- server link support for Oracle and MSSQL
- add -I support to dbicdump
$self->_dbic_stmt($table_class, 'set_primary_key', @$pks)
if @$pks;
+ # Sort unique constraints by constraint name for repeatable results (rels
+ # are sorted as well elsewhere.)
+ @uniqs = sort { $a->[0] cmp $b->[0] } @uniqs;
+
foreach my $uniq (@uniqs) {
my ($name, $cols) = @$uniq;
$self->_dbic_stmt($table_class,'add_unique_constraint', $name, $cols);
$t->cleanup;
+$t->dump_test(
+ classname => 'DBICTest::Schema::_sorted_uniqs',
+ test_db_class => 'make_dbictest_db_multi_unique',
+ regexes => {
+ Bar => [
+ qr/->add_unique_constraint\("uniq1_unique".*->add_unique_constraint\("uniq2_unique"/s,
+ ],
+ },
+);
+
+$t->cleanup;
+
# test naming => { monikers => 'plural' }
$t->dump_test(
classname => 'DBICTest::Schema::_plural_monikers',
q|INSERT INTO bar VALUES (4,1)|,
);
-END { unlink($fn); }
+END { unlink($fn) unless $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP}; }
1;
q|INSERT INTO bar VALUES (4,1)|,
);
-END { unlink($fn); }
+END { unlink($fn) unless $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP}; }
1
q|INSERT INTO bar VALUES (4,1)|,
);
-END { unlink($fn); }
+END { unlink($fn) unless $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP}; }
1;
q|INSERT INTO bar VALUES (4,1)|,
);
-END { unlink($fn); }
+END { unlink($fn) unless $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP}; }
1
--- /dev/null
+package make_dbictest_db_multi_unique;
+
+use strict;
+use warnings;
+use DBI;
+use dbixcsl_test_dir qw/$tdir/;
+
+eval { require DBD::SQLite };
+my $class = $@ ? 'SQLite2' : 'SQLite';
+
+my $fn = "$tdir/dbictest_multi_unique.db";
+
+unlink($fn);
+our $dsn = "dbi:$class:dbname=$fn";
+my $dbh = DBI->connect($dsn);
+$dbh->do('PRAGMA SYNCHRONOUS = OFF');
+
+$dbh->do($_) for (
+ q|CREATE TABLE foo (
+ fooid INTEGER PRIMARY KEY,
+ footext TEXT DEFAULT 'footext',
+ foodt TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+ )|,
+ q|CREATE TABLE bar (
+ barid INTEGER PRIMARY KEY,
+ uniq1 INT UNIQUE,
+ uniq2 INT UNIQUE,
+ fooref INTEGER REFERENCES foo(fooid)
+ )|,
+ q|INSERT INTO foo (fooid, footext) VALUES (1,'Foo text for number 1')|,
+ q|INSERT INTO foo (fooid, footext) VALUES (2,'Foo record associated with the Bar with barid 3')|,
+ q|INSERT INTO foo (fooid, footext) VALUES (3,'Foo text for number 3')|,
+ q|INSERT INTO foo (fooid, footext) VALUES (4,'Foo text for number 4')|,
+ q|INSERT INTO bar VALUES (1,1,1,4)|,
+ q|INSERT INTO bar VALUES (2,2,2,3)|,
+ q|INSERT INTO bar VALUES (3,3,3,2)|,
+ q|INSERT INTO bar VALUES (4,4,4,1)|,
+);
+
+END { unlink($fn) unless $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP}; }
+
+1;
q|INSERT INTO bars VALUES (4,1)|,
);
-END { unlink($fn); }
+END { unlink($fn) unless $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP}; }
1;
q|INSERT INTO RouteChange VALUES (1,1,3)|,
);
-END { unlink($fn); }
+END { unlink($fn) unless $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP}; }
1;