From be608c694172d6536b8d48efea5bae4c338fdca6 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Mon, 10 Sep 2012 15:31:05 -0400 Subject: [PATCH] Move allow_nested_modifiers to the driver level, provide a wrapper for it, and add that to the Pg test setup as an example Signed-off-by: Mike Rylander Signed-off-by: Thomas Berezansky Signed-off-by: Lebbeous Fogle-Weekley --- .../Application/Storage/Driver/Pg/QueryParser.pm | 2 ++ .../lib/OpenILS/Application/Storage/QueryParser.pm | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm index cbfd99c1ef..d566a37926 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm @@ -380,6 +380,8 @@ sub initialize { sub TEST_SETUP { + __PACKAGE__->allow_nested_modifiers(1); + __PACKAGE__->add_search_field_id_map( series => seriestitle => 1 => 1 ); __PACKAGE__->add_search_field_id_map( series => seriestitle => 1 => 1 ); diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm index 6f948efbb0..0be69cb06e 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm @@ -65,6 +65,15 @@ sub operators { return $parser_config{$class}{operators}; } +sub allow_nested_modifiers { + my $class = shift; + my $v = shift; + $class = ref($class) || $class; + + $parser_config{$class}{allow_nested_modifiers} = $v if (defined $v); + return $parser_config{$class}{allow_nested_modifiers}; +} + sub filters { my $class = shift; $class = ref($class) || $class; @@ -650,7 +659,7 @@ sub decompose { warn "Encountered search modifier: $1\n" if $self->debug; $_ = $'; - if (!($struct->top_plan || $parser_config{QueryParser}->{allow_nested_modifiers})) { + if (!($struct->top_plan || $parser_config{$pkg}->{allow_nested_modifiers})) { warn " Search modifiers only allowed at the top level of the query\n" if $self->debug; } else { $struct->new_modifier($1); @@ -663,7 +672,7 @@ sub decompose { my $mod = $1; $_ = $'; - if (!($struct->top_plan || $parser_config{QueryParser}->{allow_nested_modifiers})) { + if (!($struct->top_plan || $parser_config{$pkg}->{allow_nested_modifiers})) { warn " Search modifiers only allowed at the top level of the query\n" if $self->debug; } elsif ($2 =~ /^[ty1]/i) { $struct->new_modifier($mod); -- 2.43.2