@@ -6,6 +6,10 @@ def self.like_operator
66 @@like_operator ||= ::ActiveRecord ::Base . connection . adapter_name . in? ( %w[ PostgreSQL PostGIS ] ) ? 'ILIKE' : 'LIKE'
77 end
88
9+ def self . logical_comparators
10+ ActiveScaffold ::Finder ::LOGICAL_COMPARATORS if ActiveScaffold ::Finder . const_defined? :LOGICAL_COMPARATORS
11+ end
12+
913 module ClassMethods
1014 def self . extended ( klass )
1115 return unless klass . active_scaffold_config
@@ -231,21 +235,21 @@ def condition_for_range(column, value, like_pattern = nil)
231235 [ '(%<search_sql>s BETWEEN ? AND ?)' , value [ :from ] , value [ :to ] ]
232236 elsif ActiveScaffold ::Finder ::NUMERIC_COMPARATORS . include? ( value [ :opt ] )
233237 [ "%<search_sql>s #{ value [ :opt ] } ?" , value [ :from ] ]
234- elsif ActiveScaffold ::Finder :: LOGICAL_COMPARATORS . include? ( value [ :opt ] )
238+ elsif ActiveScaffold ::Finder . logical_comparators & .include? ( value [ :opt ] )
235239 operator =
236240 case value [ :opt ]
237241 when 'all_tokens' then 'AND'
238242 when 'any_token' then 'OR'
239243 end
240- parser = ActiveScaffold ::Bridges ::LogicalQueryParser ::TokensGrammar :: Parser . new ( operator ) if operator
241- [ logical_search_condition ( column , value [ :from ] , parser ) ]
244+ parser = ActiveScaffold ::Bridges ::LogicalQueryParser ::KeywordQueryParser . new ( operator ) if operator
245+ [ logical_search_condition ( column , value [ :from ] , parser || :: LogicalQueryParser ) ]
242246 end
243247 end
244248
245- def logical_search_condition ( column , search , parser = nil )
249+ def logical_search_condition ( column , search , parser )
246250 model = column . active_record_class
247251 subquery = alias_query_for_same_table_exists ( model . all ) if column . logical_search . any? ( Hash )
248- query = :: LogicalQueryParser . search ( search , subquery || model , column . logical_search , parser : parser )
252+ query = parser . search ( search , subquery || model , column . logical_search )
249253 if subquery
250254 model . where ( same_table_exists_subquery ( query ) )
251255 else
@@ -526,7 +530,6 @@ def condition_for_null_type(column, value, like_pattern = nil)
526530 doesnt_begin_with : 'not_?%' ,
527531 doesnt_end_with : 'not_%?'
528532 } . freeze
529- LOGICAL_COMPARATORS = [ ] . freeze
530533 NULL_COMPARATORS = %w[ null not_null ] . freeze
531534 DATE_COMPARATORS = %w[ PAST FUTURE RANGE ] . freeze
532535 DATE_UNITS = %w[ DAYS WEEKS MONTHS YEARS ] . freeze
0 commit comments