From: Peter Rabbitson Date: Wed, 15 Jun 2011 07:21:59 +0000 (+0200) Subject: Do not consider non-sequence oracle triggers during seq detection X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=630eee4175ed202f2fdf8965d6299162cf04bf55;p=dbsrgits%2FDBIx-Class-Historic.git Do not consider non-sequence oracle triggers during seq detection --- diff --git a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm index 12a14d3..961b447 100644 --- a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm +++ b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm @@ -164,7 +164,7 @@ sub _dbh_get_autoinc_seq { 'ALL_TRIGGERS', [qw/TRIGGER_BODY TABLE_OWNER TRIGGER_NAME/], { - $schema ? (OWNER => $schema) : (), + OWNER => $schema, TABLE_NAME => $table || $source_name, TRIGGERING_EVENT => { -like => '%INSERT%' }, # this will also catch insert_or_update TRIGGER_TYPE => { -like => '%BEFORE%' }, # we care only about 'before' triggers @@ -174,6 +174,7 @@ sub _dbh_get_autoinc_seq { # to find all the triggers that mention the column in question a simple # regex grep since the trigger_body above is a LONG and hence not searchable + # via -like my @triggers = ( map { my %inf; @inf{qw/body schema name/} = @$_; \%inf } ( grep @@ -182,10 +183,15 @@ sub _dbh_get_autoinc_seq { ) ); - # extract all sequence names mentioned in each trigger - for (@triggers) { - $_->{sequences} = [ $_->{body} =~ / ( "? [\.\w\"\-]+ "? ) \. nextval /xig ]; - } + # extract all sequence names mentioned in each trigger, throw away + # triggers without apparent sequences + @triggers = map { + my @seqs = $_->{body} =~ / ( [\.\w\"\-]+ ) \. nextval /xig; + @seqs + ? { %$_, sequences => \@seqs } + : () + ; + } @triggers; my $chosen_trigger;