Reputation: 1110
How to construct a mysql query:
SELECT *
FROM table
WHERE (key->>"$.k1", key->>"$.k2") IN ((1, "string1"), (2, "string2"))
with SQLAlchemy?
I tried to use text
but with no luck:
select([table.c.value]).where(
text('(key->>"$.k1", key->>"$.k2") IN :pairs)').bindparams(
pairs=[(1, "string1"), (2, "string2")]
)
)
This code produced:
SELECT *
FROM table
WHERE (key->>"$.k1", key->>"$.k2") IN NULL
Upvotes: 1
Views: 222
Reputation: 1110
Ilja Everilä, thanks!
The following code works:
select([table.c.value]).where(
tuple_(
text('key->>"$.k1"'),
text('key->>"$.k2"'),
).in_([[1, 'string1'], [2, 'string']])
)
Upvotes: 1