[Bast-commits] r4017 - in trunk/DBIx-Class-Schema-Loader: . t t/lib
ilmari at dev.catalyst.perl.org
ilmari at dev.catalyst.perl.org
Sat Feb 2 21:27:08 GMT 2008
Author: ilmari
Date: 2008-02-02 21:27:07 +0000 (Sat, 02 Feb 2008)
New Revision: 4017
Modified:
trunk/DBIx-Class-Schema-Loader/Changes
trunk/DBIx-Class-Schema-Loader/t/14ora_common.t
trunk/DBIx-Class-Schema-Loader/t/lib/dbixcsl_common_tests.pm
Log:
Fix auto-inc column cration for the Oracle tests
Modified: trunk/DBIx-Class-Schema-Loader/Changes
===================================================================
--- trunk/DBIx-Class-Schema-Loader/Changes 2008-02-02 15:45:56 UTC (rev 4016)
+++ trunk/DBIx-Class-Schema-Loader/Changes 2008-02-02 21:27:07 UTC (rev 4017)
@@ -3,6 +3,7 @@
Not yet released
- Add support for load_namespaces-style class layout.
- Fix test skip count for main skip_rels block
+ - Fix auto-inc column cration for the Oracle tests
0.04004 Thu Nov 15, 2007
- Fix Win32 test skip counts for good (RT #30568, Kenichi Ishigaki)
Modified: trunk/DBIx-Class-Schema-Loader/t/14ora_common.t
===================================================================
--- trunk/DBIx-Class-Schema-Loader/t/14ora_common.t 2008-02-02 15:45:56 UTC (rev 4016)
+++ trunk/DBIx-Class-Schema-Loader/t/14ora_common.t 2008-02-02 21:27:07 UTC (rev 4017)
@@ -8,7 +8,25 @@
my $tester = dbixcsl_common_tests->new(
vendor => 'Oracle',
- auto_inc_pk => 'SERIAL NOT NULL PRIMARY KEY',
+ auto_inc_pk => 'INTEGER NOT NULL PRIMARY KEY',
+ auto_inc_cb => sub {
+ my ($table, $col) = @_;
+ return (
+ qq{ CREATE SEQUENCE ${table}_${col}_seq START WITH 1 INCREMENT BY 1},
+ qq{
+ CREATE OR REPLACE TRIGGER ${table}_${col}_trigger
+ BEFORE INSERT ON ${table}
+ FOR EACH ROW
+ BEGIN
+ SELECT ${table}_${col}_seq.nextval INTO :NEW.${col} FROM dual;
+ END;
+ }
+ );
+ },
+ auto_inc_drop_cb => sub {
+ my ($table, $col) = @_;
+ return qq{ DROP SEQUENCE ${table}_${col}_seq };
+ },
dsn => $dsn,
user => $user,
password => $password,
Modified: trunk/DBIx-Class-Schema-Loader/t/lib/dbixcsl_common_tests.pm
===================================================================
--- trunk/DBIx-Class-Schema-Loader/t/lib/dbixcsl_common_tests.pm 2008-02-02 15:45:56 UTC (rev 4016)
+++ trunk/DBIx-Class-Schema-Loader/t/lib/dbixcsl_common_tests.pm 2008-02-02 21:27:07 UTC (rev 4017)
@@ -526,6 +526,7 @@
$self->{_created} = 1;
+ my $make_auto_inc = $self->{auto_inc_cb} || sub {};
my @statements = (
qq{
CREATE TABLE loader_test1 (
@@ -533,6 +534,7 @@
dat VARCHAR(32) NOT NULL UNIQUE
) $self->{innodb}
},
+ $make_auto_inc->(qw/loader_test1 id/),
q{ INSERT INTO loader_test1 (dat) VALUES('foo') },
q{ INSERT INTO loader_test1 (dat) VALUES('bar') },
@@ -546,6 +548,7 @@
UNIQUE (dat2, dat)
) $self->{innodb}
},
+ $make_auto_inc->(qw/loader_test2 id/),
q{ INSERT INTO loader_test2 (dat, dat2) VALUES('aaa', 'zzz') },
q{ INSERT INTO loader_test2 (dat, dat2) VALUES('bbb', 'yyy') },
@@ -768,6 +771,7 @@
loader_test11 INTEGER
) $self->{innodb}
},
+ $make_auto_inc->(qw/loader_test10 id10/),
qq{
CREATE TABLE loader_test11 (
@@ -777,6 +781,7 @@
FOREIGN KEY (loader_test10) REFERENCES loader_test10 (id10)
) $self->{innodb}
},
+ $make_auto_inc->(qw/loader_test11 id11/),
(q{ ALTER TABLE loader_test10 ADD CONSTRAINT } .
q{ loader_test11_fk FOREIGN KEY (loader_test11) } .
@@ -866,6 +871,11 @@
LOADER_TEST23
LoAdEr_test24
/;
+
+ my @tables_auto_inc = (
+ [ qw/loader_test1 id/ ],
+ [ qw/loader_test2 id/ ],
+ );
my @tables_reltests = qw/
loader_test4
@@ -890,6 +900,11 @@
loader_test11
loader_test10
/;
+
+ my @tables_advanced_auto_inc = (
+ [ qw/loader_test10 id10/ ],
+ [ qw/loader_test11 id11/ ],
+ );
my @tables_inline_rels = qw/
loader_test13
@@ -904,13 +919,15 @@
my @tables_rescan = qw/ loader_test30 /;
my $drop_fk_mysql =
- q{ALTER TABLE loader_test10 DROP FOREIGN KEY loader_test11_fk;};
+ q{ALTER TABLE loader_test10 DROP FOREIGN KEY loader_test11_fk};
my $drop_fk =
- q{ALTER TABLE loader_test10 DROP CONSTRAINT loader_test11_fk;};
+ q{ALTER TABLE loader_test10 DROP CONSTRAINT loader_test11_fk};
my $dbh = $self->dbconnect(0);
+ my $drop_auto_inc = $self->{auto_inc_drop_cb} || sub {};
+
unless($self->{skip_rels}) {
$dbh->do("DROP TABLE $_") for (@tables_reltests);
unless($self->{vendor} =~ /sqlite/i) {
@@ -921,6 +938,7 @@
$dbh->do($drop_fk);
}
$dbh->do("DROP TABLE $_") for (@tables_advanced);
+ $dbh->do($_) for map { $drop_auto_inc->(@$_) } @tables_advanced_auto_inc;
}
unless($self->{no_inline_rels}) {
$dbh->do("DROP TABLE $_") for (@tables_inline_rels);
@@ -931,6 +949,7 @@
$dbh->do("DROP TABLE $_") for (@tables_rescan);
}
$dbh->do("DROP TABLE $_") for (@tables);
+ $dbh->do($_) for map { $drop_auto_inc->(@$_) } @tables_auto_inc;
$dbh->disconnect;
}
More information about the Bast-commits
mailing list