my $schema;
-foreach my $info (@info) {
- my ($dsn, $user, $pass) = @$info;
+foreach my $conn_idx (0..1) {
+ my ($dsn, $user, $pass) = @{ $info[$conn_idx] };
next unless $dsn;
- $schema = DBICTest::Schema->connect($dsn, $user, $pass);
+ $schema = DBICTest::Schema->connect($dsn, $user, $pass, {
+ auto_savepoint => 1,
+ quote_char => q["],
+ name_sep => q[.],
+ });
my $dbh = $schema->storage->dbh;
my $sg = Scope::Guard->new(\&cleanup);
- eval { $dbh->do("DROP TABLE artist") };
+ eval { $dbh->do(q[DROP TABLE "artist"]) };
$dbh->do(<<EOF);
- CREATE TABLE artist (
- artistid INT PRIMARY KEY,
- name VARCHAR(255),
- charfield CHAR(10),
- rank INT DEFAULT 13
+ CREATE TABLE "artist" (
+ "artistid" INT PRIMARY KEY,
+ "name" VARCHAR(255),
+ "charfield" CHAR(10),
+ "rank" INT DEFAULT 13
)
EOF
- eval { $dbh->do("DROP GENERATOR gen_artist_artistid") };
- $dbh->do('CREATE GENERATOR gen_artist_artistid');
- eval { $dbh->do("DROP TRIGGER artist_bi") };
+ eval { $dbh->do(q[DROP GENERATOR "gen_artist_artistid"]) };
+ $dbh->do('CREATE GENERATOR "gen_artist_artistid"');
+ eval { $dbh->do('DROP TRIGGER "artist_bi"') };
$dbh->do(<<EOF);
- CREATE TRIGGER artist_bi FOR artist
+ CREATE TRIGGER "artist_bi" FOR "artist"
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
- IF (NEW.artistid IS NULL) THEN
- NEW.artistid = GEN_ID(gen_artist_artistid,1);
+ IF (NEW."artistid" IS NULL) THEN
+ NEW."artistid" = GEN_ID("gen_artist_artistid",1);
END
EOF
my $new = $ars->create({ name => 'foo' });
ok($new->artistid, "Auto-PK worked");
+# test savepoints
+# eval {
+# $schema->txn_do(sub {
+# eval {
+# $schema->txn_do(sub {
+# $ars->create({ name => 'in_savepoint' });
+# die "rolling back savepoint";
+# });
+# };
+# ok ((not $ars->search({ name => 'in_savepoint' })->first),
+# 'savepoint rolled back');
+# $ars->create({ name => 'in_outer_txn' });
+# die "rolling back outer txn";
+# });
+# };
+# ok ((not $ars->search({ name => 'in_outer_txn' })->first),
+# 'outer txn rolled back');
+
# test explicit key spec
$new = $ars->create ({ name => 'bar', artistid => 66 });
is($new->artistid, 66, 'Explicit PK worked');
$new->discard_changes;
is($new->artistid, 66, 'Explicit PK assigned');
+ lives_ok {
+ $new->update({ name => 'baz' })
+ } 'update survived';
+ $new->discard_changes;
+ is $new->name, 'baz', 'row updated';
+
# test populate
lives_ok (sub {
my @pop;
# count what we did so far
is ($ars->count, 6, 'Simple count works');
+# test UPDATE
+ lives_ok {
+ $schema->resultset('Artist')
+ ->search({name => 'foo'})
+ ->update({rank => 4 });
+ } 'Can update a column';
+
+ my ($updated) = $schema->resultset('Artist')->search({name => 'foo'});
+ is $updated->rank, 4, 'and the update made it to the database';
+
+
# test LIMIT support
my $lim = $ars->search( {},
{
# test blobs (stolen from 73oracle.t)
SKIP: {
- eval { $dbh->do('DROP TABLE bindtype_test') };
+ eval { $dbh->do('DROP TABLE "bindtype_test2"') };
$dbh->do(q[
- CREATE TABLE bindtype_test
+ CREATE TABLE "bindtype_test2"
(
- id INT PRIMARY KEY,
- bytea INT,
- a_blob BLOB,
- a_clob BLOB SUB_TYPE TEXT
+ "id" INT PRIMARY KEY,
+ "bytea" INT,
+ "a_blob" BLOB,
+ "a_clob" BLOB SUB_TYPE TEXT
)
]);
- last SKIP; # XXX blob ops cause segfaults!
-
my %binstr = ( 'small' => join('', map { chr($_) } ( 1 .. 127 )) );
$binstr{'large'} = $binstr{'small'} x 1024;
my $maxloblen = length $binstr{'large'};
local $dbh->{'LongReadLen'} = $maxloblen;
- my $rs = $schema->resultset('BindType');
+ my $rs = $schema->resultset('BindType2');
my $id = 0;
foreach my $type (qw( a_blob a_clob )) {
};
return unless $dbh;
- eval { $dbh->do('DROP TRIGGER artist_bi') };
+ eval { $dbh->do('DROP TRIGGER "artist_bi"') };
diag $@ if $@;
- eval { $dbh->do('DROP GENERATOR gen_artist_artistid') };
+ eval { $dbh->do('DROP GENERATOR "gen_artist_artistid"') };
diag $@ if $@;
- foreach my $table (qw/artist bindtype_test/) {
- eval { $dbh->do("DROP TABLE $table") };
+ foreach my $table (qw/"artist" "bindtype_test"/) {
+ eval { $dbh->do(q[DROP TABLE "$table"]) };
#diag $@ if $@;
}
}