From: Tom Bloor Date: Wed, 9 Mar 2016 19:05:38 +0000 (+0000) Subject: Skip trying to create sequences in Oracle X-Git-Tag: v1.00103_5~1^2~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fpeople%2FTBSliver%2Foracle-sequence-ignore;p=dbsrgits%2FDBIx-Class-Fixtures.git Skip trying to create sequences in Oracle In Oracle, unlike in Postgres, you have to completely drop and recreate a sequence if you want to change the current value - or do custom increment/decrement logic for it. This means that making this work in a universal way is extremely difficult if not impossible. If this proves to be an issue in the future, this can be revisited. --- diff --git a/lib/DBIx/Class/Fixtures.pm b/lib/DBIx/Class/Fixtures.pm index 1afc90c..5f5f92e 100644 --- a/lib/DBIx/Class/Fixtures.pm +++ b/lib/DBIx/Class/Fixtures.pm @@ -1394,6 +1394,8 @@ sub populate { ## Now we need to do some db specific cleanup ## this probably belongs in a more isolated space. Right now this is ## to just handle postgresql SERIAL types that use Sequences + ## Will completely ignore sequences in Oracle due to having to drop + ## and recreate them my $table = $rs->result_source->name; for my $column(my @columns = $rs->result_source->columns) { @@ -1402,14 +1404,18 @@ sub populate { $self->msg("- updating sequence $sequence"); $rs->result_source->storage->dbh_do(sub { my ($storage, $dbh, @cols) = @_; - $self->msg( - my $sql = sprintf("SELECT setval(?, (SELECT max(%s) FROM %s));",$dbh->quote_identifier($column),$dbh->quote_identifier($table)) - ); - my $sth = $dbh->prepare($sql); - $sth->bind_param(1,$sequence); - - my $rv = $sth->execute or die $sth->errstr; - $self->msg("- $sql"); + if ( $dbh->{Driver}->{Name} eq "Oracle" ) { + $self->msg("- Cannot change sequence values in Oracle"); + } else { + $self->msg( + my $sql = sprintf("SELECT setval(?, (SELECT max(%s) FROM %s));",$dbh->quote_identifier($column),$dbh->quote_identifier($table)) + ); + my $sth = $dbh->prepare($sql); + $sth->bind_param(1,$sequence); + + my $rv = $sth->execute or die $sth->errstr; + $self->msg("- $sql"); + } }); } }