[Bast-commits] r4736 - in DBIx-Class/0.08/trunk: .
lib/DBIx/Class/Storage lib/DBIx/Class/Storage/DBI
lukes at dev.catalyst.perl.org
lukes at dev.catalyst.perl.org
Wed Aug 6 19:36:01 BST 2008
Author: lukes
Date: 2008-08-06 19:36:01 +0100 (Wed, 06 Aug 2008)
New Revision: 4736
Modified:
DBIx-Class/0.08/trunk/Changes
DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Pg.pm
DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/mysql.pm
Log:
added with_deferred_fk_checks functionality to storage
Modified: DBIx-Class/0.08/trunk/Changes
===================================================================
--- DBIx-Class/0.08/trunk/Changes 2008-08-06 18:32:00 UTC (rev 4735)
+++ DBIx-Class/0.08/trunk/Changes 2008-08-06 18:36:01 UTC (rev 4736)
@@ -1,6 +1,7 @@
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
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Pg.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Pg.pm 2008-08-06 18:32:00 UTC (rev 4735)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Pg.pm 2008-08-06 18:36:01 UTC (rev 4736)
@@ -13,6 +13,13 @@
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});
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/mysql.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/mysql.pm 2008-08-06 18:32:00 UTC (rev 4735)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/mysql.pm 2008-08-06 18:36:01 UTC (rev 4736)
@@ -7,6 +7,14 @@
# __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};
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm 2008-08-06 18:32:00 UTC (rev 4735)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm 2008-08-06 18:36:01 UTC (rev 4736)
@@ -709,6 +709,28 @@
}
}
+=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) = @_;
More information about the Bast-commits
mailing list