From: Matt S Trout Date: Tue, 21 Aug 2007 18:50:00 +0000 (+0000) Subject: arrayrefs for on_connect_do X-Git-Tag: v0.08010~79 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1bd1640b34158fbef63af8118cecfcde4c81be99;p=dbsrgits%2FDBIx-Class.git arrayrefs for on_connect_do --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 9e621ab..3338b93 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -795,9 +795,10 @@ sub _do_query { $action->($self); } else { - $self->debugobj->query_start($action) if $self->debug(); - $self->_dbh->do($action); - $self->debugobj->query_end($action) if $self->debug(); + my @to_run = (ref $action eq 'ARRAY') ? (@$action) : ($action); + $self->_query_start(@to_run); + $self->_dbh->do(@to_run); + $self->_query_end(@to_run); } return $self; diff --git a/t/92storage_on_connect_do.t b/t/92storage_on_connect_do.t index a736272..0c35923 100644 --- a/t/92storage_on_connect_do.t +++ b/t/92storage_on_connect_do.t @@ -14,13 +14,19 @@ my $schema = DBICTest->init_schema( ok $schema->connection( DBICTest->_database, { - on_connect_do => ['CREATE TABLE TEST_empty (id INTEGER)'], + on_connect_do => [ + 'CREATE TABLE TEST_empty (id INTEGER)', + [ 'INSERT INTO TEST_empty VALUES (?)', {}, 2 ], + ], on_disconnect_do => [\&check_exists, 'DROP TABLE TEST_empty', \&check_dropped], }, ), 'connection()'; -ok $schema->storage->dbh->do('SELECT 1 FROM TEST_empty'), 'on_connect_do() worked'; +is_deeply + $schema->storage->dbh->selectall_arrayref('SELECT * FROM TEST_empty'), + [ [ 2 ] ], + 'on_connect_do() worked'; eval { $schema->storage->dbh->do('SELECT 1 FROM TEST_nonexistent'); }; ok $@, 'Searching for nonexistent table dies';