Subject: | dbic::Storage::DBI on_connect_do fn/param in connect_info should also accept scalar |
on_connect_do should accept also scalar value -- string which contains
one SQL statement. Patch included.
Subject: | dbic_on_connect_do.patch |
diff -r f497971c2c6f DBIx-Class-0.08100/lib/DBIx/Class/Storage/DBI.pm
--- a/DBIx-Class-0.08100/lib/DBIx/Class/Storage/DBI.pm Mon Apr 20 14:26:33 2009 +0200
+++ b/DBIx-Class-0.08100/lib/DBIx/Class/Storage/DBI.pm Mon Apr 20 14:28:44 2009 +0200
@@ -471,6 +471,11 @@
=over
+=item a scalar
+
+This contains one SQL statement to execute.
+
+
=item an array reference
This contains SQL statements to execute in order. Each element contains
@@ -944,14 +949,17 @@
$self->_conn_tid(threads->tid) if $INC{'threads.pm'};
my $connection_do = $self->on_connect_do;
- $self->_do_connection_actions($connection_do) if ref($connection_do);
+ $self->_do_connection_actions($connection_do) if defined($connection_do);
}
sub _do_connection_actions {
my $self = shift;
my $connection_do = shift;
- if (ref $connection_do eq 'ARRAY') {
+ if (!ref $connection_do) {
+ $self->_do_query($connection_do);
+ }
+ elsif (ref $connection_do eq 'ARRAY') {
$self->_do_query($_) foreach @$connection_do;
}
elsif (ref $connection_do eq 'CODE') {