From: Jess Robinson Date: Tue, 31 Jul 2007 23:28:55 +0000 (+0000) Subject: Passes tests again! X-Git-Tag: v0.900201~98 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=52558dc45676830cfaf5a902b069caf45fa72541;p=dbsrgits%2FDBIx-Class-Journal.git Passes tests again! Bugfix in DBIx::Class::Schema::Journal::txn_do, for cases where all insert values are empty, bugfix needed in dbic really.. ;) --- diff --git a/lib/DBIx/Class/Schema/Journal.pm b/lib/DBIx/Class/Schema/Journal.pm index 21a4815..daeb8c8 100644 --- a/lib/DBIx/Class/Schema/Journal.pm +++ b/lib/DBIx/Class/Schema/Journal.pm @@ -37,7 +37,7 @@ sub exception_action sub connection { my $self = shift; - $self->next::method(@_); + my $schema = $self->next::method(@_); # print STDERR join(":", $self->sources), "\n"; @@ -82,6 +82,8 @@ sub connection $self->_journal_schema->deploy(); $self->_journal_schema->class('ChangeSet')->belongs_to('user', @{$self->journal_user}); $self->_journal_schema->storage->disconnect(); + + return $schema; } sub get_audit_log_class_name @@ -128,10 +130,13 @@ sub txn_do my $cs = $self->_journal_schema->resultset('ChangeSet'); $self->txn_begin; - my $changeset = $cs->create({ ( $self->_journal_schema->current_user() ? ( user_id => $self->_journal_schema->current_user()) : () ), -# user_id => $self->_journal_schema->current_user(), - session_id => $self->_journal_schema->current_session(), - }); + my %changesetdata = ( $self->_journal_schema->current_user() ? ( 'user_id', $self->_journal_schema->current_user()) : () ), + ( $self->_journal_schema->current_session() ? ( session_id => $self->_journal_schema->current_session() ) : () ); + if(!%changesetdata) + { + %changesetdata = ( ID => undef ); + } + my $changeset = $cs->create({ %changesetdata }); $self->_journal_schema->current_changeset($changeset->ID); $self->next::method($code); diff --git a/t/lib/DBICTest.pm b/t/lib/DBICTest.pm index bd6725a..2945da9 100644 --- a/t/lib/DBICTest.pm +++ b/t/lib/DBICTest.pm @@ -58,7 +58,19 @@ sub init_schema { my $dbuser = $ENV{"DBICTEST_DBUSER"} || ''; my $dbpass = $ENV{"DBICTEST_DBPASS"} || ''; - my $schema = DBICTest::Schema->compose_connection('DBICTest' => $dsn, $dbuser, $dbpass); + my $schema; + my @connect_info = ($dsn, $dbuser, $dbpass, { AutoCommit => 1 }); + + if ($args{compose_connection}) { + $schema = DBICTest::Schema->compose_connection( + 'DBICTest', @connect_info + ); + } else { + $schema = DBICTest::Schema->compose_namespace('DBICTest') + ->connect(@connect_info); + print STDERR "Created Schema: ", ref($schema), "\n"; + } +# my $schema = DBICTest::Schema->compose_connection('DBICTest' => $dsn, $dbuser, $dbpass); # $schema->storage->on_connect_do(['PRAGMA synchronous = OFF']); if ( !$args{no_deploy} ) { __PACKAGE__->deploy_schema( $schema ); @@ -83,15 +95,15 @@ sub deploy_schema { my $self = shift; my $schema = shift; - if ($ENV{"DBICTEST_SQLT_DEPLOY"}) { +# if ($ENV{"DBICTEST_SQLT_DEPLOY"}) { return $schema->deploy(); - } else { - open IN, "t/lib/sqlite.sql"; - my $sql; - { local $/ = undef; $sql = ; } - close IN; - ($schema->storage->dbh->do($_) || print "Error on SQL: $_\n") for split(/;\n/, $sql); - } +# } else { +# open IN, "t/lib/sqlite.sql"; +# my $sql; +# { local $/ = undef; $sql = ; } +# close IN; +# ($schema->storage->dbh->do($_) || print "Error on SQL: $_\n") for split(/;\n/, $sql); +# } } =head2 populate_schema