Open NanoMeko opened 6 years ago
Same here.
Seems to be a side-effect of how distinct
works in ActiveRecord. See https://github.com/rails/rails/issues/17706
SELECT DISTINCT users.*
won't work if there is a json column. The solution would be to switch to using SELECT DISTINCT ON (users.id) users.*
@dwbutler has there been any resolution for this?
@NanoMeko were you ever able to resolve this?
Yeap, I decided to build my own group relationships with ActiveRecord 🤷🏽♂️
On Fri, 12 Jul 2019 at 08:56, Kevin Collignon notifications@github.com wrote:
@NanoMeko https://github.com/NanoMeko were you ever able to resolve this?
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/dwbutler/groupify/issues/74?email_source=notifications&email_token=AAYESWKOULAHZ6UQ4RU24TDP7AMJZA5CNFSM4FQ3SXW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZYYPNI#issuecomment-510756789, or mute the thread https://github.com/notifications/unsubscribe-auth/AAYESWL3PLOUQ6WO5E7UQX3P7AMJZANCNFSM4FQ3SXWQ .
[30] pry(main)> g.members.count (0.7ms) SELECT DISTINCT COUNT(DISTINCT "users"."id") FROM "users" INNER JOIN "group_memberships" ON "users"."id" = "group_memberships"."member_id" WHERE "group_memberships"."group_id" = $1 AND "group_memberships"."group_type" = $2 AND "group_memberships"."member_type" = $3 [["group_id", 4], ["group_type", "Group"], ["member_type", "User"]] => 1
so far so good.
[31] pry(main)> g.members.first ActiveRecord::StatementInvalid: PG::UndefinedFunction: ERROR: could not identify an equality operator for type json LINE 1: SELECT DISTINCT "users". FROM "users" INNER JOIN "group_me... ^ : SELECT DISTINCT "users". FROM "users" INNER JOIN "group_memberships" ON "users"."id" = "group_memberships"."member_id" WHERE "group_memberships"."group_id" = $1 AND "group_memberships"."group_type" = $2 AND "group_memberships"."member_type" = $3 ORDER BY "users"."id" ASC LIMIT $4 from /Users/.../.gem/ruby/2.3.0/gems/activerecord-5.0.6/lib/active_record/connection_adapters/postgresql_adapter.rb:657:in `prepare' \