# check for bad data
my $bad_slice = sub {
- my ($msg, $slice_idx) = @_;
- $self->throw_exception(sprintf "%s for populate slice:\n%s",
+ my ($msg, $col_idx, $slice_idx) = @_;
+ $self->throw_exception(sprintf "%s for column '%s' in populate slice:\n%s",
$msg,
+ $cols->[$col_idx],
Data::Dumper::Concise::Dumper({
map { $cols->[$_] => $data->[$slice_idx][$_] } (0 .. $#$cols)
}),
if ($is_literal_sql) {
if (not ref $val) {
- $bad_slice->('bind found where literal SQL expected', $datum_idx);
+ $bad_slice->('bind found where literal SQL expected', $col_idx, $datum_idx);
}
elsif ((my $reftype = ref $val) ne 'SCALAR') {
$bad_slice->("$reftype reference found where literal SQL expected",
- $datum_idx);
+ $col_idx, $datum_idx);
}
elsif ($$val ne $$sqla_bind){
$bad_slice->("inconsistent literal SQL value, expecting: '$$sqla_bind'",
- $datum_idx);
+ $col_idx, $datum_idx);
}
}
elsif (my $reftype = ref $val) {
$bad_slice->("$reftype reference found where bind expected",
- $datum_idx);
+ $col_idx, $datum_idx);
}
}
}
);
}
- $self->_query_start( $sql, @bind );
+ $self->_query_start( $sql, ['__BULK__'] );
my $sth = $self->sth($sql);
my $rv = do {
}
};
- $self->_query_end( $sql, @bind );
+ $self->_query_end( $sql, ['__BULK__'] );
return (wantarray ? ($rv, $sth, @bind) : $rv);
}
is($link7->url, undef, 'Link 7 url');
is($link7->title, 'gtitle', 'Link 7 title');
-# test _execute_array_empty (insert_bulk with all literal sql)
my $rs = $schema->resultset('Artist');
$rs->delete;
+
+# test _execute_array_empty (insert_bulk with all literal sql)
+
$rs->populate([
(+{
name => \"'DT'",
$rs->delete;
+# test mixed binds with literal sql
+
+$rs->populate([
+ (+{
+ name => \"'DT'",
+ rank => 500,
+ charfield => \"'mtfnpy'",
+ }) x 5
+]);
+
+is((grep {
+ $_->name eq 'DT' &&
+ $_->rank == 500 &&
+ $_->charfield eq 'mtfnpy'
+} $rs->all), 5, 'populate with all literal SQL');
+
+$rs->delete;
+
+###
+
throws_ok {
$rs->populate([
{