[Bast-commits] r4739 -
DBIx-Class-Preview/1.000/trunk/lib/DBIx/Class/Schema
lukes at dev.catalyst.perl.org
lukes at dev.catalyst.perl.org
Thu Aug 7 02:13:06 BST 2008
Author: lukes
Date: 2008-08-07 02:13:06 +0100 (Thu, 07 Aug 2008)
New Revision: 4739
Modified:
DBIx-Class-Preview/1.000/trunk/lib/DBIx/Class/Schema/Preview.pm
Log:
added support for latest DBIC no FK checks functionality
Modified: DBIx-Class-Preview/1.000/trunk/lib/DBIx/Class/Schema/Preview.pm
===================================================================
--- DBIx-Class-Preview/1.000/trunk/lib/DBIx/Class/Schema/Preview.pm 2008-08-07 00:07:20 UTC (rev 4738)
+++ DBIx-Class-Preview/1.000/trunk/lib/DBIx/Class/Schema/Preview.pm 2008-08-07 01:13:06 UTC (rev 4739)
@@ -45,35 +45,39 @@
$schema->txn_do(
sub {
- foreach my $source_name ($schema->sources) {
- my $source = $schema->source($source_name);
- if ($source->can('previewed')) {
- my $original_rs = $schema->resultset($source->source_name);
- my $previewed_rs = $source->previewed->resultset;
+ $schema->storage->with_deferred_fk_checks(
+ sub {
+ foreach my $source_name ($schema->sources) {
+ my $source = $schema->source($source_name);
+ if ($source->can('previewed')) {
+ my $original_rs = $schema->resultset($source->source_name);
+ my $previewed_rs = $source->previewed->resultset;
+
+ my $dirty_previewed_rs = $previewed_rs->search({ dirty => 1, deleted => 0 });
+ while (my $dirty_row = $dirty_previewed_rs->next) {
+ my $original_row = $original_rs->find($dirty_row->id);
+ my %dirty_cols = $dirty_row->get_columns;
+ delete $dirty_cols{dirty};
+ delete $dirty_cols{deleted};
+
+ if ($original_row) {
+ $original_row->update(\%dirty_cols);
+ } else {
+ $original_rs->create(\%dirty_cols);
+ }
+ }
+ $dirty_previewed_rs->update({ dirty => 0 });
- my $dirty_previewed_rs = $previewed_rs->search({ dirty => 1, deleted => 0 });
- while (my $dirty_row = $dirty_previewed_rs->next) {
- my $original_row = $original_rs->find($dirty_row->id);
- my %dirty_cols = $dirty_row->get_columns;
- delete $dirty_cols{dirty};
- delete $dirty_cols{deleted};
-
- if ($original_row) {
- $original_row->update(\%dirty_cols);
- } else {
- $original_rs->create(\%dirty_cols);
- }
- }
- $dirty_previewed_rs->update({ dirty => 0 });
-
- my $deleted_previewed_rs = $previewed_rs->search({ deleted => 1 });
- while (my $deleted_row = $deleted_previewed_rs->next) {
- my $original_row = $original_rs->find($deleted_row->id);
- $deleted_row->delete();
- $original_row->delete;
+ my $deleted_previewed_rs = $previewed_rs->search({ deleted => 1 });
+ while (my $deleted_row = $deleted_previewed_rs->next) {
+ my $original_row = $original_rs->find($deleted_row->id);
+ $deleted_row->delete();
+ $original_row->delete;
+ }
+ }
}
- }
- }
+ }
+ );
}
);
}
More information about the Bast-commits
mailing list