start using HAVING instead of manually building joins

This commit is contained in:
Bilal
2020-04-29 07:21:39 +02:00
parent 8f7b94f8cd
commit fe96f682db
2 changed files with 7 additions and 64 deletions

View File

@@ -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?