Skip to content
Browse files

fixed issue #20 illegal sql when external method return empty condition.

  • Loading branch information...
1 parent 29875ce commit c16d385799a7589a6fc35ed95d018c123d2ffaed @abenari abenari committed Apr 30, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/scoped_search/query_builder.rb
View
2 lib/scoped_search/query_builder.rb
@@ -420,7 +420,7 @@ def to_sql(builder, definition, &block)
# Defines the to_sql method for AST AND/OR operators
module LogicalOperatorNode
def to_sql(builder, definition, &block)
- fragments = children.map { |c| c.to_sql(builder, definition, &block) }.compact.map { |sql| "(#{sql})" }
+ fragments = children.map { |c| c.to_sql(builder, definition, &block) }.map { |sql| "(#{sql})" unless sql.blank? }.compact
fragments.empty? ? nil : "#{fragments.join(" #{operator.to_s.upcase} ")}"
end
end

0 comments on commit c16d385

Please sign in to comment.
Something went wrong with that request. Please try again.