From 6e8c062baa520c772bebe815d6afce11f7dae7c5 Mon Sep 17 00:00:00 2001 From: Kenichi Ishigaki Date: Sun, 14 Nov 2010 06:18:08 +0000 Subject: [PATCH] resolved #61958 --- lib/DBD/SQLite.pm | 1 + t/37_regexp.t | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/DBD/SQLite.pm b/lib/DBD/SQLite.pm index 5839ef2..d7d4e06 100644 --- a/lib/DBD/SQLite.pm +++ b/lib/DBD/SQLite.pm @@ -175,6 +175,7 @@ sub install_collation { # (see http://www.sqlite.org/vtab.html#xfindfunction) sub regexp { use locale; + return if !defined $_[0] || !defined $_[1]; return scalar($_[1] =~ $_[0]); } diff --git a/t/37_regexp.t b/t/37_regexp.t index 5cf55d6..8936c2a 100644 --- a/t/37_regexp.t +++ b/t/37_regexp.t @@ -25,7 +25,7 @@ BEGIN { } use Test::NoWarnings; -plan tests => 2 * (1 + 2 * @regexes) * @CALL_FUNCS + 1; +plan tests => 2 * (3 + 2 * @regexes) * @CALL_FUNCS + 1; BEGIN { # Sadly perl for windows (and probably sqlite, too) may hang @@ -71,6 +71,19 @@ foreach my $call_func (@CALL_FUNCS) { my $db_antimatch = $dbh->selectcol_arrayref($sql); is_deeply(\@perl_antimatch, $db_antimatch, "NOT REGEXP '$regex'"); } + + # null + { + my $sql = "SELECT txt from regexp_test WHERE txt REGEXP NULL " + . "COLLATE perllocale"; + my $db_match = $dbh->selectcol_arrayref($sql); + + is_deeply([], $db_match, "REGEXP NULL"); + + $sql =~ s/REGEXP/NOT REGEXP/; + my $db_antimatch = $dbh->selectcol_arrayref($sql); + is_deeply([], $db_antimatch, "NOT REGEXP NULL"); + } } }