From: Peter Rabbitson Date: Tue, 23 Feb 2010 11:01:31 +0000 (+0000) Subject: Cleanup code (hopefully no functional changes) X-Git-Tag: v0.08120~3^2~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=032b2366870757d95623b65fd3272f3a466ba51a;p=dbsrgits%2FDBIx-Class.git Cleanup code (hopefully no functional changes) --- diff --git a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm index 2644d43..c6491ab 100644 --- a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm +++ b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm @@ -35,9 +35,9 @@ sub deployment_statements { my ($schema, $type, $version, $dir, $sqltargs, @rest) = @_; $sqltargs ||= {}; - my $quote_char = $self->schema->storage->{'_sql_maker_opts'}->{'quote_char'}; - $sqltargs->{quote_table_names} = 0 unless $quote_char; - $sqltargs->{quote_field_names} = 0 unless $quote_char; + my $quote_char = $self->schema->storage->sql_maker->quote_char; + $sqltargs->{quote_table_names} = $quote_char ? 1 : 0; + $sqltargs->{quote_field_names} = $quote_char ? 1 : 0; my $oracle_version = eval { $self->_get_dbh->get_info(18) }; @@ -60,49 +60,38 @@ sub _dbh_last_insert_id { sub _dbh_get_autoinc_seq { my ($self, $dbh, $source, $col) = @_; - # look up the correct sequence automatically - my $sql = q{ - SELECT trigger_body FROM ALL_TRIGGERS t - WHERE t.table_name = ? - AND t.triggering_event = 'INSERT' - AND t.status = 'ENABLED' - }; - - # trigger_body is a LONG - local $dbh->{LongReadLen} = 64 * 1024 if ($dbh->{LongReadLen} < 64 * 1024); - - my $sth; + my $sql_maker = $self->sql_maker; my $source_name; - if ( ref $source->name ne 'SCALAR' ) { - $source_name = $source->name; + if ( ref $source->name eq 'SCALAR' ) { + $source_name = ${$source->name}; } else { - $source_name = ${$source->name}; + $source_name = $source->name; + $source_name = uc($source_name) unless $sql_maker->quote_char; } - unless ($self->schema->storage->{'_sql_maker_opts'}->{'quote_char'}) { - $source_name = uc($source_name); - } + # trigger_body is a LONG + local $dbh->{LongReadLen} = 64 * 1024 if ($dbh->{LongReadLen} < 64 * 1024); + + # disable default bindtype + local $sql_maker->{bindtype} = 'normal'; + + # look up the correct sequence automatically + my ( $schema, $table ) = $source_name =~ /(\w+)\.(\w+)/; + my ($sql, @bind) = $sql_maker->select ( + 'ALL_TRIGGERS', + ['trigger_body'], + { + $schema ? (owner => $schema) : (), + table_name => $table || $source_name, + triggering_event => 'INSERT', + status => 'ENABLED', + }, + ); + my $sth = $dbh->prepare($sql); + $sth->execute (@bind); - # check for fully-qualified name (eg. SCHEMA.TABLENAME) - if ( my ( $schema, $table ) = $source_name =~ /(\w+)\.(\w+)/ ) { - $sql = q{ - SELECT trigger_body FROM ALL_TRIGGERS t - WHERE t.owner = ? AND t.table_name = ? - AND t.triggering_event = 'INSERT' - AND t.status = 'ENABLED' - }; - $sth = $dbh->prepare($sql); - my $table_name = $self -> sql_maker -> _quote($table); - my $schema_name = $self -> sql_maker -> _quote($schema); - - $sth->execute( $schema_name, $table_name ); - } - else { - $sth = $dbh->prepare($sql); - $sth->execute( $source_name ); - } while (my ($insert_trigger) = $sth->fetchrow_array) { return $1 if $insert_trigger =~ m!("?\w+"?)\.nextval!i; # col name goes here??? }