cashapp / sqldelight

SQLDelight - Generates typesafe Kotlin APIs from SQL
https://cashapp.github.io/sqldelight/
Apache License 2.0
6.14k stars 515 forks source link

Code Generator: Support WHERE In many columns with Lists #4205

Open hfhbd opened 1 year ago

hfhbd commented 1 year ago

Description

sql-psi 0.5.0 supports https://github.com/AlecStrong/sql-psi/issues/273, now code gen should support it too:

CREATE TABLE Test(field1 INTEGER NOT NULL, field2 INTEGER NOT NULL);

selectWhereMany:
SELECT * FROM Test
WHERE (field1, field2) < (?, ?);

Should emit this code:

selectWhereMany(
     listOf(
        selectWhereManyValues(field1 = 1, field2 = 2),
        selectWhereManyValues(field1 = 2, field2 = 1),
     )
)
shellderp commented 1 year ago

sql-psi does not actually support

selectWhereMany:
SELECT * FROM Test
WHERE (field1, field2) IN ?;

it only supports lessthan/greaterthan, not IN (I think)

It also requires LP/RP around the right hand

hfhbd commented 1 year ago

Yes, fixed.