[Bast-commits] r3450 - in branches/DBIx-Class-current:
lib/DBIx/Class/Storage lib/DBIx/Class/Storage/DBI t
blblack at dev.catalyst.perl.org
blblack at dev.catalyst.perl.org
Thu May 31 21:48:32 GMT 2007
Author: blblack
Date: 2007-05-31 21:48:31 +0100 (Thu, 31 May 2007)
New Revision: 3450
Modified:
branches/DBIx-Class-current/lib/DBIx/Class/Storage/DBI.pm
branches/DBIx-Class-current/lib/DBIx/Class/Storage/DBI/NoBindVars.pm
branches/DBIx-Class-current/t/93nobindvars.t
Log:
integrate nobindvars/_prep_for_execute with the bind_params changes (also converted some arrays to arrayrefs in the arg lists of private methods)
Modified: branches/DBIx-Class-current/lib/DBIx/Class/Storage/DBI/NoBindVars.pm
===================================================================
--- branches/DBIx-Class-current/lib/DBIx/Class/Storage/DBI/NoBindVars.pm 2007-05-31 20:01:34 UTC (rev 3449)
+++ branches/DBIx-Class-current/lib/DBIx/Class/Storage/DBI/NoBindVars.pm 2007-05-31 20:48:31 UTC (rev 3450)
@@ -25,7 +25,7 @@
sub connect_info {
my $self = shift;
- my $retval = shift->next::method(@_);
+ my $retval = $self->next::method(@_);
$self->disable_sth_caching(1);
$retval;
}
@@ -38,10 +38,20 @@
sub _prep_for_execute {
my $self = shift;
- my ($sql, @bind) = $self->next::method(@_);
+ my ($sql, $bind) = $self->next::method(@_);
- $sql =~ s/\?/$self->_dbh->quote(shift(@bind))/eg;
+ # stringify args, quote via $dbh, and manually insert
+ foreach my $bound (@$bind) {
+ shift @$bound;
+ foreach my $data (@$bound) {
+ if(ref $data) {
+ $data = ''.$data;
+ }
+ $sql =~ s/\?/$self->_dbh->quote($data)/e;
+ }
+ }
+
return ($sql);
}
Modified: branches/DBIx-Class-current/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- branches/DBIx-Class-current/lib/DBIx/Class/Storage/DBI.pm 2007-05-31 20:01:34 UTC (rev 3449)
+++ branches/DBIx-Class-current/lib/DBIx/Class/Storage/DBI.pm 2007-05-31 20:48:31 UTC (rev 3450)
@@ -830,15 +830,14 @@
# easier to override in NoBindVars without duping the rest. It takes up
# all of _execute's args, and emits $sql, @bind.
sub _prep_for_execute {
- my ($self, $op, $extra_bind, $ident, @args) = @_;
+ my ($self, $op, $extra_bind, $ident, $args) = @_;
- my ($sql, @bind) = $self->sql_maker->$op($ident, @args);
+ my ($sql, @bind) = $self->sql_maker->$op($ident, @$args);
unshift(@bind,
map { ref $_ eq 'ARRAY' ? $_ : [ '!!dummy', $_ ] } @$extra_bind)
if $extra_bind;
- @bind = map { ref $_ ? ''.$_ : $_ } @bind; # stringify args
- return ($sql, @bind);
+ return ($sql, \@bind);
}
sub _execute {
@@ -847,15 +846,12 @@
if( blessed($ident) && $ident->isa("DBIx::Class::ResultSource") ) {
$ident = $ident->from();
}
-
- my ($sql, @bind) = $self->sql_maker->$op($ident, @args);
- unshift(@bind,
- map { ref $_ eq 'ARRAY' ? $_ : [ '!!dummy', $_ ] } @$extra_bind)
- if $extra_bind;
+ my ($sql, $bind) = $self->_prep_for_execute($op, $extra_bind, $ident, \@args);
+
if ($self->debug) {
my @debug_bind =
- map { defined ($_ && $_->[1]) ? qq{'$_->[1]'} : q{'NULL'} } @bind;
+ map { defined ($_ && $_->[1]) ? qq{'$_->[1]'} : q{'NULL'} } @$bind;
$self->debugobj->query_start($sql, @debug_bind);
}
@@ -865,7 +861,7 @@
my $rv = eval {
my $placeholder_index = 1;
- foreach my $bound (@bind) {
+ foreach my $bound (@$bind) {
my $attributes = {};
my($column_name, @data) = @$bound;
@@ -889,10 +885,10 @@
if ($self->debug) {
my @debug_bind =
- map { defined ($_ && $_->[1]) ? qq{'$_->[1]'} : q{'NULL'} } @bind;
+ map { defined ($_ && $_->[1]) ? qq{'$_->[1]'} : q{'NULL'} } @$bind;
$self->debugobj->query_end($sql, @debug_bind);
}
- return (wantarray ? ($rv, $sth, @bind) : $rv);
+ return (wantarray ? ($rv, $sth, @$bind) : $rv);
}
sub insert {
Modified: branches/DBIx-Class-current/t/93nobindvars.t
===================================================================
--- branches/DBIx-Class-current/t/93nobindvars.t 2007-05-31 20:01:34 UTC (rev 3449)
+++ branches/DBIx-Class-current/t/93nobindvars.t 2007-05-31 20:48:31 UTC (rev 3450)
@@ -21,13 +21,17 @@
{ # Fake storage driver for mysql + no bind variables
package DBIx::Class::Storage::DBI::MySQLNoBindVars;
+ use Class::C3;
use base qw/
+ DBIx::Class::Storage::DBI::NoBindVars
DBIx::Class::Storage::DBI::mysql
- DBIx::Class::Storage::DBI::NoBindVars
/;
$INC{'DBIx/Class/Storage/DBI/MySQLNoBindVars.pm'} = 1;
}
+# XXX Class::C3 doesn't like some of the Storage stuff happening late...
+Class::C3::reinitialize();
+
my $schema = DBICTest::Schema->clone;
$schema->storage_type('::DBI::MySQLNoBindVars');
$schema->connection($dsn, $user, $pass);
More information about the Bast-commits
mailing list