Given a Entry model that has a relation (I've tested with has_one, belongs_to, has_one through ) called project
and a pg_search_scope :search_by_text,
then trying to get the ids while also including the project association
Entry.includes(:project).search_by_text("unexpurgated").ids
raises an error similar to #238
ActiveRecord::StatementInvalid: PG::GroupingError: ERROR: column "pg_search_87d05cd08817497883161d.rank" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: ...61d.pg_search_id GROUP BY "entries"."id" ORDER BY pg_search_...
Workaround is to .reorder('') before calling .ids, ie.
Entry.includes(:project).search_by_text("unexpurgated").reorder("").ids
Note that all of these are fine:
Entry.includes(:project).search_by_text("unexpurgated").pluck(:id)
Entry.search_by_text("unexpurgated").ids