Upstream sync

This commit was merged in pull request #1.
This commit is contained in:
Senad Uka
2020-04-16 10:04:13 +02:00
parent 3de6bd22d8
commit afbfdb87cd
9 changed files with 686 additions and 598 deletions

View File

@@ -42,14 +42,17 @@ module PgSearchable
def ts_add_scope
class_eval do
scope ts_scope_method, ->(value) { ts_search(value) }
scope ts_scope_method, ->(value) do
resulting_ids = ts_search(value).map(&:id)
where(id: resulting_ids)
end
end
end
def ts_search(value)
return if @ts_search_fields.blank? || value.blank?
includes(@ts_joins).references(:all).where(
TextToSqlQuery.new(value, @ts_search_fields, @default_field, @ts_search_fields_mappings).where_clause)
TextToSqlQuery.new(value, @ts_search_fields, @default_field, @ts_search_fields_mappings).where_clause).distinct
end
def should_update_cache_field?