Unable to invite user (invalid SQL)

(Martin Hasoň) #1

If I want invite user or reset password, postgres throws error:

ERROR:  for SELECT DISTINCT, ORDER BY expressions must appear in select list at character 342
STATEMENT:  SELECT COUNT(*) FROM (SELECT DISTINCT "invites".* FROM "invites" LEFT OUTER JOIN "users" ON "users"."id" = "invites"."user_id" LEFT OUTER JOIN "user_stats" ON "user_stats"."user_id" = "users"."id" WHERE ("invites"."deleted_at" IS NULL) AND "invites"."invited_by_id" = 1 AND (invites.email IS NOT NULL) AND (invites.user_id IS NULL) ORDER BY CASE WHEN invites.user_id IS NOT NULL THEN 0 ELSE 1 END, user_stats.time_read DESC, invites.redeemed_at DESC OFFSET 0) subquery_for_count

If I remove DISTINCT from SQL query, everything is alright.

(Jeff Atwood) #2

Can you repro this @techapj?

(Arpit Jalan) #4

I am unable to repro this on latest Discourse version.

@hason can you PM me complete error log? (info, backtrace & env)