Added quote char test, supported quoting in S::A subclass for joins
[dbsrgits/DBIx-Class.git] / t / 13oracle.t
CommitLineData
e565d25e 1use lib qw(lib t/lib);
2use DBICTest::Schema;
3
4use Test::More;
5
6my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_ORA_${_}" } qw/DSN USER PASS/};
7
8plan skip_all, 'Set $ENV{DBICTEST_ORA_DSN}, _USER and _PASS to run this test. ' .
9 'Warning: This test drops and creates a table called \'artist\''
10 unless ($dsn && $user && $pass);
11
4bb63dac 12plan tests => 4;
e565d25e 13
14DBICTest::Schema->compose_connection('OraTest' => $dsn, $user, $pass);
15
16my $dbh = OraTest::Artist->storage->dbh;
17
18eval {
19 $dbh->do("DROP SEQUENCE artist_seq");
20 $dbh->do("DROP TABLE artist");
21};
22$dbh->do("CREATE SEQUENCE artist_seq START WITH 1 MAXVALUE 999999 MINVALUE 0");
23$dbh->do("CREATE TABLE artist (artistid NUMBER(12), name VARCHAR(255))");
24$dbh->do("ALTER TABLE artist ADD (CONSTRAINT artist_pk PRIMARY KEY (artistid))");
25$dbh->do(qq{
26 CREATE OR REPLACE TRIGGER artist_insert_trg
27 BEFORE INSERT ON artist
28 FOR EACH ROW
29 BEGIN
30 IF :new.artistid IS NULL THEN
31 SELECT artist_seq.nextval
32 INTO :new.artistid
33 FROM DUAL;
34 END IF;
35 END;
36});
37
38OraTest::Artist->load_components('PK::Auto::Oracle');
39
4bb63dac 40# test primary key handling
e565d25e 41my $new = OraTest::Artist->create({ name => 'foo' });
e565d25e 42ok($new->artistid, "Oracle Auto-PK worked");
43
4bb63dac 44# test LIMIT support
45for (1..6) {
46 OraTest::Artist->create({ name => 'Artist ' . $_ });
47}
48my $it = OraTest::Artist->search( {},
49 { rows => 3,
50 offset => 2,
51 order_by => 'artistid' }
52);
53is( $it->count, 3, "LIMIT count ok" );
54is( $it->next->name, "Artist 2", "iterator->next ok" );
55$it->next;
56$it->next;
57is( $it->next, undef, "next past end of resultset ok" );
58
59# clean up our mess
e565d25e 60$dbh->do("DROP SEQUENCE artist_seq");
61$dbh->do("DROP TABLE artist");
62
631;