From: Yuval Kogman Date: Tue, 29 Jul 2008 21:31:41 +0000 (+0000) Subject: if journalling schema is not the main schema we need to call txn_do on that too X-Git-Tag: v0.900201~89 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4233d9a1f831c499533407729b3ecdba58329605;p=dbsrgits%2FDBIx-Class-Journal.git if journalling schema is not the main schema we need to call txn_do on that too --- diff --git a/lib/DBIx/Class/Schema/Journal.pm b/lib/DBIx/Class/Schema/Journal.pm index 8b50081..5f56edb 100644 --- a/lib/DBIx/Class/Schema/Journal.pm +++ b/lib/DBIx/Class/Schema/Journal.pm @@ -172,7 +172,7 @@ sub txn_do my $jschema = $self->_journal_schema; - my $code; + my $code = $user_code; my $current_changeset = $jschema->current_changeset; if ( !$current_changeset || $self->journal_nested_changesets ) @@ -187,13 +187,19 @@ sub txn_do # wrap the thunk with a new changeset creation $code = sub { - my $changeset = $jschema->journal_create_changeset( parent_id => $current_changeset ); - local $current_changeset_ref->{changeset} = $changeset->ID; - $user_code->(@_); - }; + my $changeset = $jschema->journal_create_changeset( parent_id => $current_changeset ); + local $current_changeset_ref->{changeset} = $changeset->ID; + $user_code->(@_); + }; + } - $self->next::method($code || $user_code); + if ( $jschema != $self ) { + my $inner_code = $code; + $code = sub { $jschema->txn_do($inner_code, @_) }; + } + + return $self->next::method($code, @args); } sub changeset_user