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;
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.