# 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 {
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);
}
my $rv = eval {
my $placeholder_index = 1;
- foreach my $bound (@bind) {
+ foreach my $bound (@$bind) {
my $attributes = {};
my($column_name, @data) = @$bound;
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 {
sub connect_info {
my $self = shift;
- my $retval = shift->next::method(@_);
+ my $retval = $self->next::method(@_);
$self->disable_sth_caching(1);
$retval;
}
sub _prep_for_execute {
my $self = shift;
- my ($sql, @bind) = $self->next::method(@_);
-
- $sql =~ s/\?/$self->_dbh->quote(shift(@bind))/eg;
+ my ($sql, $bind) = $self->next::method(@_);
+
+ # 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);
}
{ # Fake storage driver for mysql + no bind variables
package DBIx::Class::Storage::DBI::MySQLNoBindVars;
+ use Class::C3;
use base qw/
- DBIx::Class::Storage::DBI::mysql
DBIx::Class::Storage::DBI::NoBindVars
+ DBIx::Class::Storage::DBI::mysql
/;
$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);