sub _insert_ARRAYREFREF {
my ($self, $data) = @_;
- my ($cols, $subquery) = @$data;
- if (not $subuery) {
- # if somehow someone is calling this with the original SQLA api,
- # pass it along
+ my ($cols, $subquery) = @$$data;
+ if (not $subquery) {
return next::method($self, $cols);
}
- my $subsql, @subbind = @$subquery;
-
my @fields = sort @$cols;
- my ($sql, @bind) = $self->_insert_values($data);
+ my ($sql, @bind) = next::method($self, $subquery);
- $_ = $self->_quote($_) foreach @$fields;
- $sql = "( ".join(", ", sort @$fields).") ".$sql;
+ # as_query wraps in brackets. drop them
+ $_ = $self->_quote($_) for @fields;
+ $sql = "( ".join(", ", @fields).") " . substr($sql, 1, -1);
return ($sql, @bind);
-
- # when passing ARRAYREFREF with [cols], SQLA drops INTO $table (cols)
- # we inject the returned sql here
- #$_ = $self->_quote($_) foreach @fields;
- # $sql = "( ".join(", ", @fields).") ".$sql;
- my $sql = sprintf(
- 'INSERT INTO %s( %s ) VALUES', $_[0]->_quote($_[1])
- );
}
sub _recurse_fields {
my ($sql, $proto_bind) = $self->_prep_for_execute (
'insert',
$source,
- [ $proto_data || ($cols => $data) ],
+ [ $proto_data || \[ $cols => $data ] ],
);
if (! @$proto_bind and keys %$value_type_by_col_idx) {
}
else {
# bind_param_array doesn't work if there are no binds
- $self->_dbh_execute_inserts_with_no_binds( $sth, scalar(@$data)+1 );
+ $self->_dbh_execute_inserts_with_no_binds( $sth, ref $data eq 'ARRAY' ? (scalar(@$data)+1) : 1 );
}
};
use DDP; use Data::Dumper;
my $q = $schema->resultset('Artist')
->search({
- artist => { '<' => $schema->resultset('Artist')->search->get_column('id')->max_rs->as_query },
- name => 'foo'
+ },
+ {
+ columns => [qw/name rank/]
})->as_query;
use DDP; p $q;
#p $q;
#diag Dumper($q);
#p $schema->resultset('Artist')->result_source;
#p Dumper $q;
-$schema->storage->insert_bulk($schema->resultset('Artist')->result_source, [qw/artistid name/], $q);
+$schema->storage->insert_bulk($schema->resultset('Artist')->result_source, [qw/name rank/], $q);