use strict;
use warnings;
-use base qw/DBIx::Class::Storage::DBI/;
+use base qw/DBIx::Class::Storage::DBI::SetConstraintsDeferred/;
use mro 'c3';
use DBIx::Class::Carp;
-use Scope::Guard ();
-use Context::Preserve 'preserve_context';
use Try::Tiny;
use List::Util 'first';
use namespace::clean;
my ($schema, $type, $version, $dir, $sqltargs, @rest) = @_;
$sqltargs ||= {};
- 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;
if (
! exists $sqltargs->{producer_args}{oracle_version}
$self->next::method($schema, $type, $version, $dir, $sqltargs, @rest);
}
+sub insert {
+ my ($self, $source, $to_insert) = @_;
+
+ # Oracle does not understand INSERT INTO ... DEFAULT VALUES syntax
+ # Furthermore it does not have any way to insert without specifying any columns
+ # We can't fix this in SQLMaker::Oracle because it doesn't know which column to add to the statement
+ unless (%$to_insert)
+ {
+ my ($col) = $source->columns;
+ $to_insert = { $col => \'DEFAULT' };
+ }
+
+ return $self->next::method($source, $to_insert);
+}
+
sub _dbh_last_insert_id {
my ($self, $dbh, $source, @columns) = @_;
my @ids = ();
sub _dbh_execute {
#my ($self, $dbh, $sql, $bind, $bind_attrs) = @_;
- my ($self, $bind) = @_[0,3];
+ my ($self, $sql, $bind) = @_[0,2,3];
# Turn off sth caching for multi-part LOBs. See _prep_for_execute below
local $self->{disable_sth_caching} = 1 if first {
return shift->$next(@_)
if $self->transaction_depth;
- # cheat the blockrunner - we do want to rerun things regardless of outer state
+ # cheat the blockrunner we are just about to create
+ # we do want to rerun things regardless of outer state
local $self->{_in_do_block};
return DBIx::Class::Storage::BlockRunner->new(
storage => $self,
- run_code => $next,
- run_args => \@_,
wrap_txn => 0,
retry_handler => sub {
# ORA-01003: no statement parsed (someone changed the table somehow,
# invalidating your cursor.)
- return 0 if ($_[0]->retried_count or $_[0]->last_exception !~ /ORA-01003/);
-
- # re-prepare towards new table data
- if (my $dbh = $_[0]->storage->_dbh) {
- delete $dbh->{CachedKids}{$_[0]->run_args->[2]};
+ if (
+ $_[0]->failed_attempt_count == 1
+ and
+ $_[0]->last_exception =~ /ORA-01003/
+ and
+ my $dbh = $_[0]->storage->_dbh
+ ) {
+ delete $dbh->{CachedKids}{$sql};
+ return 1;
+ }
+ else {
+ return 0;
}
- return 1;
},
- )->run;
+ )->run( $next, @_ );
}
sub _dbh_execute_for_fetch {
the L<DBIx::Class::Relationship> name is shortened and appended with half of an
MD5 hash.
-See L<DBIx::Class::Storage/"relname_to_table_alias">.
+See L<DBIx::Class::Storage::DBI/relname_to_table_alias>.
=cut
my $alias = $self->next::method(@_);
# we need to shorten here in addition to the shortening in SQLA itself,
- # since the final relnames are a crucial for the join optimizer
+ # since the final relnames are crucial for the join optimizer
return $self->sql_maker->_shorten_identifier($alias);
}
-=head2 with_deferred_fk_checks
-
-Runs a coderef between:
-
- alter session set constraints = deferred
- ...
- alter session set constraints = immediate
-
-to defer foreign key checks.
-
-Constraints must be declared C<DEFERRABLE> for this to work.
-
-=cut
-
-sub with_deferred_fk_checks {
- my ($self, $sub) = @_;
-
- my $txn_scope_guard = $self->txn_scope_guard;
-
- $self->_do_query('alter session set constraints = deferred');
-
- my $sg = Scope::Guard->new(sub {
- $self->_do_query('alter session set constraints = immediate');
- });
-
- return
- preserve_context { $sub->() } after => sub { $txn_scope_guard->commit };
-}
-
=head1 ATTRIBUTES
Following additional attributes can be used in resultsets.
# ORDER SIBLINGS BY
# firstname ASC
-=head1 AUTHOR
+=head1 FURTHER QUESTIONS?
-See L<DBIx::Class/AUTHOR> and L<DBIx::Class/CONTRIBUTORS>.
+Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
-=head1 LICENSE
+=head1 COPYRIGHT AND LICENSE
-You may distribute this code under the same terms as Perl itself.
+This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
+by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
+redistribute it and/or modify it under the same terms as the
+L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.
=cut