lib/scoped_search/definition.rb in scoped_search-2.3.6 vs lib/scoped_search/definition.rb in scoped_search-2.3.7
- old
+ new
@@ -147,13 +147,13 @@
register_named_scope! unless klass.respond_to?(:search_for)
register_complete_for! unless klass.respond_to?(:complete_for)
end
-
+
attr_accessor :profile, :default_order
-
+
def fields
@profile ||= :default
@profile_fields[@profile] ||= {}
end
@@ -174,15 +174,15 @@
# this method is used by the syntax auto completer to suggest operators.
def operator_by_field_name(name)
field = field_by_name(name)
return [] if field.nil?
- return field.operators if field.operators
- return ['= ', '!= '] if field.set?
- return ['= ', '> ', '< ', '<= ', '>= ','!= '] if field.numerical?
- return ['= ', '!= ', '~ ', '!~ '] if field.textual?
- return ['= ', '> ', '< '] if field.temporal?
+ return field.operators if field.operators
+ return ['= ', '!= '] if field.set?
+ return ['= ', '> ', '< ', '<= ', '>= ','!= ', '^ ', '!^ '] if field.numerical?
+ return ['= ', '!= ', '~ ', '!~ ', '^ ', '!^ '] if field.textual?
+ return ['= ', '> ', '< '] if field.temporal?
raise ScopedSearch::QueryNotSupported, "could not verify '#{name}' type, this can be a result of a definition error"
end
NUMERICAL_REGXP = /^\-?\d+(\.\d+)?$/
@@ -228,11 +228,11 @@
if @klass.ancestors.include?(ActiveRecord::Base)
case ActiveRecord::VERSION::MAJOR
when 2
@klass.named_scope(:search_for, lambda { |*args| ScopedSearch::QueryBuilder.build_query(self, args[0], args[1]) })
when 3
- @klass.scope(:search_for, lambda { |*args|
- find_options = ScopedSearch::QueryBuilder.build_query(self, args[0], args[1])
+ @klass.scope(:search_for, lambda { |*args|
+ find_options = ScopedSearch::QueryBuilder.build_query(self, args[0], args[1])
search_scope = @klass.scoped
search_scope = search_scope.where(find_options[:conditions]) if find_options[:conditions]
search_scope = search_scope.includes(find_options[:include]) if find_options[:include]
search_scope = search_scope.joins(find_options[:joins]) if find_options[:joins]
search_scope = search_scope.order(find_options[:order]) if find_options[:order]