start using HAVING instead of manually building joins
This commit is contained in:
@@ -55,16 +55,14 @@ module PgSearchable
|
||||
|
||||
def ts_search(value)
|
||||
return if @ts_search_fields.blank? || value.blank?
|
||||
model = ancestors.first
|
||||
sql_query_object = TextToSqlQuery.new(
|
||||
value,
|
||||
@ts_search_fields,
|
||||
@default_fields,
|
||||
@ts_search_fields_mappings,
|
||||
@ts_joins,
|
||||
model
|
||||
@ts_joins
|
||||
)
|
||||
joins(sql_query_object.join_clause).where(sql_query_object.where_clause).distinct
|
||||
distinct.joins(sql_query_object.join_clause).group(:id).having(sql_query_object.where_clause)
|
||||
end
|
||||
|
||||
def should_update_cache_field?
|
||||
|
||||
Reference in New Issue
Block a user