From: Rafael Kitover Date: Sat, 12 Jun 2010 09:19:56 +0000 (-0400) Subject: improve Oracle sequence detection and related test output X-Git-Tag: v0.08123~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9d7d2f00fee8d3a531f45dcf0fa71f42134402b4;p=dbsrgits%2FDBIx-Class.git improve Oracle sequence detection and related test output --- diff --git a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm index 8b64b3c..05e2c8b 100644 --- a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm +++ b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm @@ -146,12 +146,12 @@ sub _dbh_get_autoinc_seq { $sth->execute (@bind); while (my ($insert_trigger, $schema) = $sth->fetchrow_array) { - my ($seq_name) = $insert_trigger =~ m!("?[.\w]+"?)\.nextval!i; + my ($seq_name) = $insert_trigger =~ m!("?[.\w"]+?"?)\.nextval!i; next unless $seq_name; if ($seq_name !~ /\./) { - $seq_name = "${schema}.${seq_name}"; + $seq_name = join '.' => map $self->sql_maker->_quote($_), $schema, $seq_name; } return $seq_name; diff --git a/t/73oracle.t b/t/73oracle.t index 3192acb..911fad5 100644 --- a/t/73oracle.t +++ b/t/73oracle.t @@ -38,7 +38,7 @@ use DBIC::SqlMakerTest; my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_ORA_${_}" } qw/DSN USER PASS/}; # optional: -my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_ORA2_${_}" } qw/DSN USER PASS/}; +my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_ORA_EXTRAUSER_${_}" } qw/DSN USER PASS/}; plan skip_all => 'Set $ENV{DBICTEST_ORA_DSN}, _USER and _PASS to run this test. ' . 'Warning: This test drops and creates tables called \'artist\', \'cd\', \'track\' and \'sequence_test\''. @@ -657,14 +657,18 @@ if ( $schema->storage->isa('DBIx::Class::Storage::DBI::Oracle::Generic') ) { my $schema2; # test sequence detection from a different schema -if ($dsn2 && $user2) { +SKIP: { + skip ((join '', +'Set DBICTEST_ORA_EXTRAUSER_DSN, _USER and _PASS to a *DIFFERENT* Oracle user', +' to run the cross-schema autoincrement test.'), + 1) unless $dsn2 && $user2 && $user2 ne $user; + $schema2 = DBICTest::Schema->connect($dsn2, $user2, $pass2); - my $dbh = $schema->storage->dbh; - my $dbh2 = $schema2->storage->dbh; + my $schema1_dbh = $schema->storage->dbh; - $dbh->do("GRANT INSERT ON artist TO $user2"); - $dbh->do("GRANT SELECT ON artist_seq TO $user2"); + $schema1_dbh->do("GRANT INSERT ON artist TO $user2"); + $schema1_dbh->do("GRANT SELECT ON artist_seq TO $user2"); my $rs = $schema2->resultset('Artist'); @@ -672,9 +676,9 @@ if ($dsn2 && $user2) { local $rs->result_source->{name} = "${user}.artist"; lives_and { - my $row = $rs->create({ name => 'Different Schema' }); + my $row = $rs->create({ name => 'From Different Schema' }); ok $row->artistid; - } 'detected autoinc sequence across schemas'; + } 'used autoinc sequence across schemas'; } done_testing; @@ -779,7 +783,5 @@ END { $dbh->do("DROP TABLE cd"); $dbh->do("DROP TABLE bindtype_test"); }; - - eval { $dbh->do('DROP SYNONYM artist') }; } }