1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-07 22:28:47 -04:00
This commit is contained in:
Kenichi Ishigaki 2010-11-14 06:18:08 +00:00
parent bc8755654d
commit 6e8c062baa
2 changed files with 15 additions and 1 deletions

View file

@ -175,6 +175,7 @@ sub install_collation {
# (see http://www.sqlite.org/vtab.html#xfindfunction) # (see http://www.sqlite.org/vtab.html#xfindfunction)
sub regexp { sub regexp {
use locale; use locale;
return if !defined $_[0] || !defined $_[1];
return scalar($_[1] =~ $_[0]); return scalar($_[1] =~ $_[0]);
} }

View file

@ -25,7 +25,7 @@ BEGIN {
} }
use Test::NoWarnings; use Test::NoWarnings;
plan tests => 2 * (1 + 2 * @regexes) * @CALL_FUNCS + 1; plan tests => 2 * (3 + 2 * @regexes) * @CALL_FUNCS + 1;
BEGIN { BEGIN {
# Sadly perl for windows (and probably sqlite, too) may hang # 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); my $db_antimatch = $dbh->selectcol_arrayref($sql);
is_deeply(\@perl_antimatch, $db_antimatch, "NOT REGEXP '$regex'"); 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");
}
} }
} }