From: Mike Rylander Date: Mon, 10 Sep 2012 19:31:05 +0000 (-0400) Subject: Move allow_nested_modifiers to the driver level, provide a wrapper for it, and add... X-Git-Tag: sprint4-merge-nov22~3468 X-Git-Url: https://git.evergreen-ils.org/?p=working%2FEvergreen.git;a=commitdiff_plain;h=be608c694172d6536b8d48efea5bae4c338fdca6;hp=264a90828359118a3b736e8de4a14a450997b4eb 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 --- 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);