Ruby ActiveRecord and sql tuple support

Does ActiveRecord support tuples in the where clause if the underlying database does?

As a result, the where clause will look something like this:

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

I tried:

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

and it didn’t work.

+4
source share
2 answers
 Person.where("(name, address) IN ((?))", ['John', '123 Main St']) 
+1
source
 tupleArray = [['John', '123 Main St'],['Jane', '124 Main St']] Person.where("(name, address) IN (#{(['(?)']*tupleArray.size).join(', ')})", *tupleArray) 
+1
source

All Articles