Do any methods / patterns exist for sanitizing an array of arrays when using it as SQL input?
Looking to implement the following style of query in ActiveRecord:
SELECT *
FROM "addresses"
WHERE ("addresses"."city", "addresses"."state", "addresses"."country") IN (
('Juneau', 'AK', 'US'),
('Albany', 'NY', 'US'),
...
)
For example:
searches = [
['Juneau', 'AK', 'US'],
['Albany', 'NY', 'US'],
]
searches_sql = searches.map do |search|
"(#{search.map { |query| Address.connection.quote(query) }.join(', ')})"
end.join(', ')
Address.where(%(("addresses"."city", "addresses"."state", "addresses"."country") IN (#{searches_sql})))
Works but relies on some manual connection escaping that doesn't seem ideal (and isn't easily generalized beyond this scope).