diff --git a/lib/DBD/SQLite/VirtualTable/PerlData.pm b/lib/DBD/SQLite/VirtualTable/PerlData.pm index 697cd08..5af9977 100644 --- a/lib/DBD/SQLite/VirtualTable/PerlData.pm +++ b/lib/DBD/SQLite/VirtualTable/PerlData.pm @@ -115,7 +115,7 @@ sub BEST_INDEX { "($op($member))"; } else { push @conditions, - "($op($member) && $op(\$vals[$ix]))"; + "($op($member) && !defined(\$vals[$ix]))"; } } elsif (SQLITE_3010000 && $op =~ /str/) { push @conditions, diff --git a/t/virtual_table/rt_99748.t b/t/virtual_table/rt_99748.t index 5315709..206680e 100644 --- a/t/virtual_table/rt_99748.t +++ b/t/virtual_table/rt_99748.t @@ -35,7 +35,7 @@ our $perl_rows = [ ]; my $tests = 14; -$tests += 1 if has_sqlite('3.6.19'); +$tests += 2 if has_sqlite('3.6.19'); plan tests => 4 + 2 * $tests + @interpolation_attempts + 9; my $dbh = connect_ok( RaiseError => 1, AutoCommit => 1 ); @@ -113,6 +113,10 @@ sub test_table { $sql = "SELECT a FROM $table WHERE c IS ?"; $res = $dbh->selectcol_arrayref($sql, {}, undef); is_deeply $res, [7], $sql; + + $sql = "SELECT a FROM $table WHERE c IS NOT ? order by a"; + $res = $dbh->selectcol_arrayref($sql, {}, undef); + is_deeply $res, [1, 4, 10, 11, 12], $sql; } }