[Bast-commits] r3860 - DBIx-Class/0.08/branches/oracle_sequence/t
plu at dev.catalyst.perl.org
plu at dev.catalyst.perl.org
Tue Nov 6 21:58:42 GMT 2007
Author: plu
Date: 2007-11-06 21:58:42 +0000 (Tue, 06 Nov 2007)
New Revision: 3860
Modified:
DBIx-Class/0.08/branches/oracle_sequence/t/73oracle.t
Log:
added tests for oracle sequence nextval
Modified: DBIx-Class/0.08/branches/oracle_sequence/t/73oracle.t
===================================================================
--- DBIx-Class/0.08/branches/oracle_sequence/t/73oracle.t 2007-11-06 21:57:44 UTC (rev 3859)
+++ DBIx-Class/0.08/branches/oracle_sequence/t/73oracle.t 2007-11-06 21:58:42 UTC (rev 3860)
@@ -11,7 +11,7 @@
'Warning: This test drops and creates tables called \'artist\', \'cd\' and \'track\''
unless ($dsn && $user && $pass);
-plan tests => 7;
+plan tests => 10;
my $schema = DBICTest::Schema->connect($dsn, $user, $pass);
@@ -19,16 +19,25 @@
eval {
$dbh->do("DROP SEQUENCE artist_seq");
+ $dbh->do("DROP SEQUENCE artist_oracle_seq");
+ $dbh->do("DROP SEQUENCE artist_oracle_otherid_seq");
+ $dbh->do("DROP SEQUENCE artist_oracle_nonpriid_seq");
$dbh->do("DROP TABLE artist");
+ $dbh->do("DROP TABLE artist_oracle");
$dbh->do("DROP TABLE cd");
$dbh->do("DROP TABLE track");
};
$dbh->do("CREATE SEQUENCE artist_seq START WITH 1 MAXVALUE 999999 MINVALUE 0");
+$dbh->do("CREATE SEQUENCE artist_oracle_seq START WITH 1 MAXVALUE 999999 MINVALUE 0");
+$dbh->do("CREATE SEQUENCE artist_oracle_otherid_seq START WITH 10 MAXVALUE 999999 MINVALUE 0");
+$dbh->do("CREATE SEQUENCE artist_oracle_nonpriid_seq START WITH 20 MAXVALUE 999999 MINVALUE 0");
$dbh->do("CREATE TABLE artist (artistid NUMBER(12), name VARCHAR(255))");
+$dbh->do("CREATE TABLE artist_oracle (artistid NUMBER(12), otherid NUMBER(12), nonpriid NUMBER(12), name VARCHAR(255))");
$dbh->do("CREATE TABLE cd (cdid NUMBER(12), artist NUMBER(12), title VARCHAR(255), year VARCHAR(4))");
$dbh->do("CREATE TABLE track (trackid NUMBER(12), cd NUMBER(12), position NUMBER(12), title VARCHAR(255), last_updated_on DATE)");
$dbh->do("ALTER TABLE artist ADD (CONSTRAINT artist_pk PRIMARY KEY (artistid))");
+$dbh->do("ALTER TABLE artist_oracle ADD (CONSTRAINT artist_oracle_pk PRIMARY KEY (artistid))");
$dbh->do(qq{
CREATE OR REPLACE TRIGGER artist_insert_trg
BEFORE INSERT ON artist
@@ -95,11 +104,22 @@
is( scalar @results, 1, "Group by with limit OK" );
}
+# test auto increment using sequences WITHOUT triggers
+$new = $schema->resultset('ArtistOracle')->create({ name => 'foo' });
+is($new->artistid, 1, "Oracle Auto-PK without trigger: First primary key");
+is($new->otherid, 10, "Oracle Auto-PK without trigger: Second primary key");
+is($new->nonpriid, 20, "Oracle Auto-PK without trigger: Non-primary key");
+
+
# clean up our mess
END {
if($dbh) {
$dbh->do("DROP SEQUENCE artist_seq");
+ $dbh->do("DROP SEQUENCE artist_oracle_seq");
+ $dbh->do("DROP SEQUENCE artist_oracle_otherid_seq");
+ $dbh->do("DROP SEQUENCE artist_oracle_nonpriid_seq");
$dbh->do("DROP TABLE artist");
+ $dbh->do("DROP TABLE artist_oracle");
$dbh->do("DROP TABLE cd");
$dbh->do("DROP TABLE track");
}
More information about the Bast-commits
mailing list