kysely-org / kysely

A type-safe typescript SQL query builder
https://kysely.dev
MIT License
9.9k stars 249 forks source link

Type errors with sql RawBuilder arbitrary where statements after updating to 0.27 #920

Closed codygordon closed 3 months ago

codygordon commented 3 months ago

Passing a full arbitrary raw sql statement into a where, which had been working fine, seems to be raising a type error for me now after updating to 0.27.

Argument of type 'RawBuilder<unknown>' is not assignable to parameter 
of type 'ExpressionOrFactory<DB, "myTableName", SqlBool>'

My use-case is a tsquery statement like this (but I get the error attempting the simple between example from the docs as well):

where(sql`search_terms @@ to_tsquery('simple', ${searchText})`)

Passing sql<undefined> type seems to clear the error – but is this intended?

koskimas commented 3 months ago

Use

sql<boolean>`whatever`

for boolean expressions.

codygordon commented 3 months ago

Thanks! Just noting the docs should probably be updated with this new requirement.

koskimas commented 3 months ago

Thanks! Just noting the docs should probably be updated with this new requirement.

Done.