Reputation: 1953
I have an ActiveRecord query:
Shareholder.where(is_company: false).distinct
which gives me the error:
ActiveRecord::StatementInvalid: PG::UndefinedFunction: ERROR: could not identify an equality operator for type json
The SQL query created by ActiveRecord:
SELECT DISTINCT "shareholders".*
FROM "shareholders"
WHERE "shareholders"."deleted" = $1 AND "shareholders"."is_company" = $2
I'm a bit puzzled that this does not work. What is wrong?
Upvotes: 2
Views: 3107
Reputation: 1209
Distinct does not work with json column, but you can try this
Shareholder.select("DISTINCT ON (shareholders.id) shareholders.*").where(is_company: false).distinct
Upvotes: 5