kysely-org / kysely

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

`eb` assumes unknown operators to be arithmetic operators #891

Open koskimas opened 4 months ago

koskimas commented 4 months ago

Consider this snippet

where(eb => eb('first_name', sql`%>>`, 'Jennifer'))

This will cause a type error since the operator is assumed to be arithmetic and the output type of the expression is string.

One way to solve this could be

where(eb => eb('first_name', sql<boolean>`%>>`, 'Jennifer'))

or we bring back the cmpr function 😬

koskimas commented 4 months ago

Or we could make boolean the default expression type. Unknown operators would create a boolean expression. That's probably a better assumption (?)