From: Jess Robinson Date: Fri, 11 May 2007 14:21:39 +0000 (+0000) Subject: Fix "inserting audit_log twice" bug, start on allowing using the same schema X-Git-Tag: v0.900201~101 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d19af36916395d9909efecb2c957d06002c6ae74;p=dbsrgits%2FDBIx-Class-Journal.git Fix "inserting audit_log twice" bug, start on allowing using the same schema --- diff --git a/lib/DBIx/Class/Journal.pm b/lib/DBIx/Class/Journal.pm index 4d362a9..19304d5 100644 --- a/lib/DBIx/Class/Journal.pm +++ b/lib/DBIx/Class/Journal.pm @@ -17,6 +17,7 @@ sub insert { my ($self) = @_; + return if($self->in_storage); ## create new transaction here? my $res = $self->next::method(); if($self->in_storage) diff --git a/lib/DBIx/Class/Schema/Journal.pm b/lib/DBIx/Class/Schema/Journal.pm index 634f96e..493837d 100644 --- a/lib/DBIx/Class/Schema/Journal.pm +++ b/lib/DBIx/Class/Schema/Journal.pm @@ -23,6 +23,15 @@ sub exception_action $self->next::method(@_); } +# sub load_classes +# { +# my $class = shift; + + +# $class->next::method(@_); + +# } + sub connection { my $self = shift; @@ -30,11 +39,20 @@ sub connection # print STDERR join(":", $self->sources), "\n"; - my $journal_schema = DBIx::Class::Schema::Journal::DB->connect(@{ $self->journal_connection || $self->storage->connect_info }); -# print STDERR "conn", $journal_schema->storage->connect_info; - if($self->journal_storage_type) + my $journal_schema; + if(!defined($self->journal_connection)) + { + ## If no connection, use the same schema/storage etc as the user + DBIx::Class::Componentised->inject_base(ref $self, 'DBIx::Class::Schema::Journal::DB'); + $journal_schema = $self; + } + else { - $journal_schema->storage_type($self->journal_storage_type); + $journal_schema = DBIx::Class::Schema::Journal::DB->connect(@{ $self->journal_connection }); + if($self->journal_storage_type) + { + $journal_schema->storage_type($self->journal_storage_type); + } } ## get our own private version of the journaling sources diff --git a/t/lib/DBICTest.pm b/t/lib/DBICTest.pm index 354d9c9..bd6725a 100644 --- a/t/lib/DBICTest.pm +++ b/t/lib/DBICTest.pm @@ -46,9 +46,12 @@ sub init_schema { my $self = shift; my %args = @_; my $db_file = "t/var/DBIxClass.db"; + my $db_audit = 't/var/Audit.db'; unlink($db_file) if -e $db_file; unlink($db_file . "-journal") if -e $db_file . "-journal"; + unlink($db_audit) if -e $db_audit; + unlink($db_audit . "-journal") if -e $db_audit . "-journal"; mkdir("t/var") unless -d "t/var"; my $dsn = $ENV{"DBICTEST_DSN"} || "dbi:SQLite:${db_file}";