7

假设底层数据库支持,ActiveRecord 是否支持 where 子句中的元组?

生成的 where 子句类似于:

where (name, address) in (('John', '123 Main St'))

我试过了:

Person.where({[:name, :address] => ['John', '123 Main St']})

它没有用。

4

2 回答 2

4
tupleArray = [['John', '123 Main St'],['Jane', '124 Main St']]
Person.where("(name, address) IN (#{(['(?)']*tupleArray.size).join(', ')})", *tupleArray)
于 2015-07-17T21:56:19.617 回答
1
Person.where("(name, address) IN ((?))", ['John', '123 Main St'])
于 2013-05-08T06:23:44.223 回答