use DBIx::Class::Carp;
use Scope::Guard ();
use Context::Preserve 'preserve_context';
-use Try::Tiny;
-use List::Util 'first';
+use DBIx::Class::_Util qw( modver_gt_or_eq modver_gt_or_eq_and_lt dbic_internal_try );
use namespace::clean;
__PACKAGE__->sql_limit_dialect ('RowNum');
$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 = ();
+ my $ci = $source->columns_info(\@columns);
foreach my $col (@columns) {
- my $seq = ($source->column_info($col)->{sequence} ||= $self->get_autoinc_seq($source,$col));
+ my $seq = ( $ci->{$col}{sequence} ||= $self->get_autoinc_seq($source,$col));
my $id = $self->_sequence_fetch( 'CURRVAL', $seq );
push @ids, $id;
}
local $dbh->{RaiseError} = 1;
local $dbh->{PrintError} = 0;
- return try {
+ ( dbic_internal_try {
$dbh->do('select 1 from dual');
1;
- } catch {
- 0;
- };
+ })
+ ? 1
+ : 0
+ ;
}
sub _dbh_execute {
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 {
+ local $self->{disable_sth_caching} = 1 if grep {
($_->[0]{_ora_lob_autosplit_part}||0)
>
(__cache_queries_with_max_lob_parts - 1)
return shift->$next(@_)
if $self->transaction_depth;
- # cheat the blockrunner we are just about to create
- # we do want to rerun things regardless of outer state
- local $self->{_in_do_block};
+ # Cheat the blockrunner we are just about to create:
+ # We *do* want to rerun things regardless of outer state
+ local $self->{_in_do_block}
+ if $self->{_in_do_block};
- return DBIx::Class::Storage::BlockRunner->new(
+ DBIx::Class::Storage::BlockRunner->new(
storage => $self,
wrap_txn => 0,
retry_handler => sub {
}
sub _dbh_execute_for_fetch {
- #my ($self, $sth, $tuple_status, @extra) = @_;
+ #my ($self, $source, $sth, $proto_bind, $cols, $data) = @_;
- # DBD::Oracle warns loudly on partial execute_for_fetch failures
- local $_[1]->{PrintWarn} = 0;
+ # Older DBD::Oracle warns loudly on partial execute_for_fetch failures
+ # before https://metacpan.org/source/PYTHIAN/DBD-Oracle-1.28/Changes#L7-9
+ local $_[2]->{PrintWarn} = 0
+ unless modver_gt_or_eq( 'DBD::Oracle', '1.28' );
shift->next::method(@_);
}
my $attrs = $self->next::method($ident, $bind);
- for my $i (0 .. $#$attrs) {
- if (keys %{$attrs->[$i]||{}} and my $col = $bind->[$i][0]{dbic_colname}) {
- $attrs->[$i]{ora_field} = $col;
- }
- }
+ # Push the column name into all bind attrs, make sure to *NOT* write into
+ # the existing $attrs->[$idx]{..} hashref, as it is cached by the call to
+ # next::method above.
+ # FIXME - this code will go away when the LobWriter refactor lands
+ $attrs->[$_]
+ and
+ keys %{ $attrs->[$_] }
+ and
+ $bind->[$_][0]{dbic_colname}
+ and
+ $attrs->[$_] = { %{$attrs->[$_]}, ora_field => $bind->[$_][0]{dbic_colname} }
+ for 0 .. $#$attrs;
$attrs;
}
if ($self->_is_lob_type($dt)) {
- # this is a hot-ish codepath, store an escape-flag in the DBD namespace, so that
- # things like Class::Unload work (unlikely but possible)
- unless ($DBD::Oracle::__DBIC_DBD_VERSION_CHECK_OK__) {
-
- # no earlier - no later
- if ($DBD::Oracle::VERSION eq '1.23') {
- $self->throw_exception(
- "BLOB/CLOB support in DBD::Oracle == 1.23 is broken, use an earlier or later ".
- "version (https://rt.cpan.org/Public/Bug/Display.html?id=46016)"
- );
- }
-
- $DBD::Oracle::__DBIC_DBD_VERSION_CHECK_OK__ = 1;
- }
+ # no earlier - no later
+ $self->throw_exception(
+ "BLOB/CLOB support in DBD::Oracle == 1.23 is broken, use an earlier or later "
+ . "version (https://rt.cpan.org/Public/Bug/Display.html?id=46016)"
+ ) if modver_gt_or_eq_and_lt( 'DBD::Oracle', '1.23', '1.24' );
return {
ora_type => $self->_is_text_lob_type($dt)