class ScopedSearch::QueryBuilder::PostgreSQLAdapter

The PostgreSQLAdapter make sure that searches are case sensitive when using the like/unlike operators, by using the PostrgeSQL-specific ILIKE operator instead of LIKE.

Public Instance Methods

sql_operator(operator, field) click to toggle source

Switches out the default LIKE operator for ILIKE in the default sql_operator method.

# File lib/scoped_search/query_builder.rb, line 454
def sql_operator(operator, field)
  raise ScopedSearch::QueryNotSupported, "the operator '#{operator}' is not supported for field type '#{field.type}'" if [:like, :unlike].include?(operator) and !field.textual?
  case operator
    when :like   then 'ILIKE'
    when :unlike then 'NOT ILIKE'
    else super(operator, field)
  end
end
to_not_sql(rhs, definition, &block) click to toggle source

Returns a NOT (...) SQL fragment that negates the current AST node's children

# File lib/scoped_search/query_builder.rb, line 464
def to_not_sql(rhs, definition, &block)
  "NOT COALESCE(#{rhs.to_sql(self, definition, &block)}, false)"
end