[Bast-commits] r4639 - DBIx-Class-Tree-NestedSet/lib/DBIx/Class/Tree
rafl at dev.catalyst.perl.org
rafl at dev.catalyst.perl.org
Fri Jul 25 01:49:38 BST 2008
Author: rafl
Date: 2008-07-25 01:49:37 +0100 (Fri, 25 Jul 2008)
New Revision: 4639
Modified:
DBIx-Class-Tree-NestedSet/lib/DBIx/Class/Tree/NestedSet.pm
Log:
Wrap insert in a transaction.
Modified: DBIx-Class-Tree-NestedSet/lib/DBIx/Class/Tree/NestedSet.pm
===================================================================
--- DBIx-Class-Tree-NestedSet/lib/DBIx/Class/Tree/NestedSet.pm 2008-07-25 00:44:36 UTC (rev 4638)
+++ DBIx-Class-Tree-NestedSet/lib/DBIx/Class/Tree/NestedSet.pm 2008-07-25 00:49:37 UTC (rev 4639)
@@ -66,7 +66,7 @@
}
sub insert {
- my $self = shift;
+ my ($self, @args) = @_;
my ($root, $left, $right) = map {
$self->tree_columns->{"${_}_column"}
@@ -79,15 +79,19 @@
});
}
- my $row = $self->next::method(@_);
+ my $row;
+ my $get_row = $self->next::can;
+ $self->result_source->schema->txn_do(sub {
+ $row = $get_row->($self, @args);
- if (!defined $row->$root) {
- $row->update({
- $root => $row->get_column( ($row->result_source->primary_columns)[0] ),
- });
+ if (!defined $row->$root) {
+ $row->update({
+ $root => $row->get_column( ($row->result_source->primary_columns)[0] ),
+ });
- $row->discard_changes;
- }
+ $row->discard_changes;
+ }
+ });
return $row;
}
More information about the Bast-commits
mailing list