1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-07 14:19:10 -04:00

fixed a case where bind param is undef (which should be converted to NULL)

This commit is contained in:
Kenichi Ishigaki 2014-10-28 16:13:46 +09:00
parent 0cd3997830
commit 9b227e74f4
2 changed files with 9 additions and 2 deletions

View file

@ -185,7 +185,7 @@ sub FILTER {
my ($self, $idxNum, $idxStr, @values) = @_;
# escape '\' and '}' in values before they are sprintf'ed into q{%s}
@values = map {quotemeta($_)} @values;
@values = map {defined $_ ? quotemeta($_) : 'NULL'} @values;
# build a method coderef to fetch matching rows
my $perl_code = 'sub {my ($self, $i) = @_; my $row = $self->row($i); '

View file

@ -42,7 +42,7 @@ my @interpolation_attempts = (
# '$0',
# '$self',
plan tests => 4 + 2 * 13 + @interpolation_attempts + 8;
plan tests => 4 + 2 * 15 + @interpolation_attempts + 8;
my $dbh = connect_ok( RaiseError => 1, AutoCommit => 1 );
@ -111,6 +111,13 @@ sub test_table {
$res = $dbh->selectcol_arrayref($sql, {}, '{');
is_deeply $res, [], $sql;
$res = $dbh->selectcol_arrayref($sql, {}, undef);
is_deeply $res, [], $sql;
$sql = "SELECT a FROM $table WHERE c IS ?";
$res = $dbh->selectcol_arrayref($sql, {}, undef);
is_deeply $res, [7], $sql;
}
sub test_match_operator {