From a1d80aaafae2c04c368056e079e1de14e3185f5e Mon Sep 17 00:00:00 2001 From: Shuuzou Asami Date: Tue, 26 Mar 2019 16:33:36 +0900 Subject: [PATCH] - add regex that escaping the backquote into '_load_filter' function. - testing code above. - fix that testing not work a little bit on groonga version 9.0.0. --- lib/AnyEvent/Groonga.pm | 1 + t/04_tut.t | 15 +++++++++++---- t/05_regression.t | 16 +++++++++++++++- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/lib/AnyEvent/Groonga.pm b/lib/AnyEvent/Groonga.pm index d973246..0bd211e 100644 --- a/lib/AnyEvent/Groonga.pm +++ b/lib/AnyEvent/Groonga.pm @@ -286,6 +286,7 @@ sub _load_filter { $json =~ s/\\/\\\\\\\\/g; $json =~ s/'/\\'/g; $json =~ s/"/\\"/g; + $json =~ s/`/\\`/g; } if ( ref $data ne 'ARRAY' ) { $json = '[' . $json . ']'; diff --git a/t/04_tut.t b/t/04_tut.t index cf0a156..bdf2e7a 100644 --- a/t/04_tut.t +++ b/t/04_tut.t @@ -5,6 +5,7 @@ use AnyEvent::Groonga; use Test::More; use FindBin; use File::Spec; +use File::Basename qw( dirname ); _cleanup(); @@ -20,6 +21,11 @@ else { plan tests => 21; } +# create data directory. +unless( -d dirname($test_database_path) ) { + mkdir( dirname($test_database_path) ) or die "can't create the data directory for groonga"; +} + `$groonga_path -n $test_database_path quit`; $g->protocol("local_db"); @@ -40,7 +46,8 @@ $result = $g->call( } )->recv; -is( $result->body, "true" ); +# return 1 on groonga version 9.0.0. +like( $result->body, qr/true|1/ ); # select $result = $g->call( select => { table => "Site" } )->recv; @@ -58,7 +65,7 @@ $result = $g->call( } )->recv; -is( $result->body, "true" ); +like( $result->body, qr/true|1/ ); # table_create Terms $result = $g->call( @@ -70,7 +77,7 @@ $result = $g->call( } )->recv; -is( $result->body, "true" ); +like( $result->body, qr/true|1/ ); # column_create Terms $result = $g->call( @@ -83,7 +90,7 @@ $result = $g->call( } )->recv; -is( $result->body, "true" ); +like( $result->body, qr/true|1/ ); # load my $data = [ diff --git a/t/05_regression.t b/t/05_regression.t index e6b9c7a..f53b462 100644 --- a/t/05_regression.t +++ b/t/05_regression.t @@ -6,6 +6,7 @@ use AnyEvent::Groonga; use Test::More; use FindBin; use File::Spec; +use File::Basename qw(dirname); unlink $_ for glob( File::Spec->catfile( $FindBin::RealBin, "data", "*") ); @@ -21,6 +22,11 @@ else{ plan tests => 2; } +# create data directory. +unless( -d dirname($test_database_path) ) { + mkdir( dirname($test_database_path) ) or die "can't create the data directory for groonga"; +} + `$groonga_path -n $test_database_path quit`; $g->protocol("local_db"); @@ -55,6 +61,9 @@ $g->call( { _key => "http://example.com/jpn", title => "日本語を含むレコード", }, + { _key => "http://example.com/swz", + title => "test record containing backquote` character.", + } ); my $result = $g->call( @@ -63,7 +72,7 @@ $g->call( values => \@data, } )->recv; - is( $result->body, 3 ); + is( $result->body, 4 ); $result = $g->call( select => { table => "Site" } )->recv; @@ -82,6 +91,11 @@ $g->call( _key => "http://example.com/jpn", title => "日本語を含むレコード", }, + { + _id => 4, + _key => "http://example.com/swz", + title => "test record containing backquote` character.", + }, ] ); }