diff --git a/lib/DBD/SQLite/VirtualTable/PerlData.pm b/lib/DBD/SQLite/VirtualTable/PerlData.pm index b2bdbf7..5112b1e 100644 --- a/lib/DBD/SQLite/VirtualTable/PerlData.pm +++ b/lib/DBD/SQLite/VirtualTable/PerlData.pm @@ -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); ' diff --git a/t/virtual_table/rt_99748.t b/t/virtual_table/rt_99748.t index 9d17d83..b289cb9 100644 --- a/t/virtual_table/rt_99748.t +++ b/t/virtual_table/rt_99748.t @@ -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 {