Revision history for DBIx::Class
0.08099_04 2008-07-24 01:00:00
+ - Functionality to storage to enable a sub to be run without FK checks
- Fixed $schema->clone bug which caused clone and source to share
internal hash refs
- Added register_extra_source methods for additional sources
}
}
+=head2 with_deferred_fk_checks
+
+=over 4
+
+=item Arguments: C<$coderef>
+
+=item Return Value: The return value of $coderef
+
+=back
+
+Storage specific method to run the code ref with FK checks deferred or
+in MySQL's case disabled entirely.
+
+=cut
+
+# Storage subclasses should override this
+sub with_deferred_fk_checks {
+ my ($self, $sub) = @_;
+
+ $sub->();
+}
+
sub connected {
my ($self) = @_;
warn "DBD::Pg 1.49 is strongly recommended"
if ($DBD::Pg::VERSION < 1.49);
+sub with_deferred_fk_checks {
+ my ($self, $sub) = @_;
+
+ $self->dbh->do('SET CONSTRAINTS ALL DEFERRED');
+ $sub->();
+}
+
sub _dbh_last_insert_id {
my ($self, $dbh, $seq) = @_;
$dbh->last_insert_id(undef, undef, undef, undef, {sequence => $seq});
# __PACKAGE__->load_components(qw/PK::Auto/);
+sub with_deferred_fk_checks {
+ my ($self, $sub) = @_;
+
+ $self->dbh->do('SET foreign_key_checks=0');
+ $sub->();
+ $self->dbh->do('SET foreign_key_checks=1');
+}
+
sub _dbh_last_insert_id {
my ($self, $dbh, $source, $col) = @_;
$dbh->{mysql_insertid};