[Bast-commits] r3700 - in DBIx-Class/0.08/trunk:
lib/DBIx/Class/Storage t
matthewt at dev.catalyst.perl.org
matthewt at dev.catalyst.perl.org
Tue Aug 21 19:50:01 GMT 2007
Author: matthewt
Date: 2007-08-21 19:50:00 +0100 (Tue, 21 Aug 2007)
New Revision: 3700
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
DBIx-Class/0.08/trunk/t/92storage_on_connect_do.t
Log:
arrayrefs for on_connect_do
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm 2007-08-21 18:29:10 UTC (rev 3699)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm 2007-08-21 18:50:00 UTC (rev 3700)
@@ -795,9 +795,10 @@
$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;
Modified: DBIx-Class/0.08/trunk/t/92storage_on_connect_do.t
===================================================================
--- DBIx-Class/0.08/trunk/t/92storage_on_connect_do.t 2007-08-21 18:29:10 UTC (rev 3699)
+++ DBIx-Class/0.08/trunk/t/92storage_on_connect_do.t 2007-08-21 18:50:00 UTC (rev 3700)
@@ -14,13 +14,19 @@
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';
More information about the Bast-commits
mailing list