Permalink
Browse files

fixed bug in commit: suggest and, or to impruve query readability.

  • Loading branch information...
abenari committed Apr 17, 2011
1 parent c9b4896 commit fe5d9615d9d3d3ba75018510653ffc76a1701606
Showing with 4 additions and 3 deletions.
  1. +3 −2 lib/scoped_search/auto_complete_builder.rb
  2. +1 −1 spec/integration/auto_complete_spec.rb
@@ -60,7 +60,8 @@ def complete_options(node)
# left hand
if is_left_hand(node)
- if (tokens.size == 1 || last_token_is(PREFIX_OPERATORS + LOGICAL_INFIX_OPERATORS))
+ if (tokens.size == 1 || last_token_is(PREFIX_OPERATORS + LOGICAL_INFIX_OPERATORS) ||
+ last_token_is(PREFIX_OPERATORS + LOGICAL_INFIX_OPERATORS, 2))
options = [:keyword]
options += [:prefix_op] unless last_token_is(PREFIX_OPERATORS)
else
@@ -168,7 +169,7 @@ def complete_key(name, field, val)
field_name = field.key_field
opts = value_conditions(field.key_field, val).merge(:limit => 20, :select => field_name, :group => field_name )
- field.key_klass.all(opts).map(&field_name).compact.map{ |f| "#{name}.#{f}"}
+ field.key_klass.all(opts).map(&field_name).compact.map{ |f| "#{name}.#{f} "}
end
# this method auto-completes values of fields that have a :complete_value marker
@@ -66,7 +66,7 @@ class ::Bar < ActiveRecord::Base; belongs_to :foo; end
end
it "should complete logical comparators" do
- Foo.complete_for('string ~ fo ').should contain("string ~ fo and", "string ~ fo or", "string ~ fo not")
+ Foo.complete_for('string ~ fo ').should contain("string ~ fo and", "string ~ fo or")
end
it "should complete prefix operators" do

0 comments on commit fe5d961

Please sign in to comment.