Ruby on rails PG运算符不存在:uuid=文本

Ruby on rails PG运算符不存在:uuid=文本,ruby-on-rails,postgresql,Ruby On Rails,Postgresql,我有一个模型对话,用户,通过有很多*连接,通过:用户对话 我有这个范围: class Conversation < ActiveRecord::Base has_many :users_conversations has_many :users, through: :users_conversations scope :by_participants, ->(ids) { joins(:users).where("users.id = ALL (ARRAY[?]

我有一个模型
对话
用户
,通过
有很多*连接,通过:用户对话

我有这个范围:

class Conversation < ActiveRecord::Base
  has_many :users_conversations
  has_many :users, through: :users_conversations

  scope :by_participants, ->(ids) {
    joins(:users).where("users.id = ALL (ARRAY[?])", ids)
  }
end
你试过这个吗

class Conversation < ActiveRecord::Base
  has_many :users_conversations
  has_many :users, through: :users_conversations

  scope :by_participants, ->(ids) {
    joins(:users).where("users.id = ALL (ARRAY[?]::uuid[])", ids)
    # it's all about ARRAY[?]::uuid[] type cast
  }
end
类对话(ids){
联接(:users).where(:users.id=ALL(数组[?]::uuid[]),id)
#这都是关于数组[?]::uuid[]类型转换的
}
结束

您的目标列是
::uuid[]
,但源列是
text
,只需键入cast并查看结果。

您是否尝试过任何(
连接(:users)。其中(“users.id=ANY(ARRAY[?]),ids)
)而不是所有?@imechemi,它不太可能解决问题,也不是我需要的
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
       : SELECT  "conversations".* FROM "conversations" INNER JOIN "users_conversations" ON "users_conversations"."conversation_id" = "conversations"."id" INNER JOIN "users" ON "users"."id" = "users_conversations"."user_id" WHERE (users.id = ALL (ARRAY['cast (6d4ff0b3-e148-40f8-87b5-d4d03577577a as uuid)','cast (432f4f6e-5832-4831-80dc-c747b8d3e742 as uuid)']))  
class Conversation < ActiveRecord::Base
  has_many :users_conversations
  has_many :users, through: :users_conversations

  scope :by_participants, ->(ids) {
    joins(:users).where("users.id = ALL (ARRAY[?]::uuid[])", ids)
    # it's all about ARRAY[?]::uuid[] type cast
  }
end