kysely-org / kysely

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

Support for `Set<>` and other kinds of iterables. #1204

Closed arthurfiorette closed 3 weeks ago

arthurfiorette commented 3 weeks ago

Not always data is organized in an array form and even currently it appears work with Set<>, TS type checker gets mad and only allows arrays.

db
  .selectFrom('Table')
  .select('field')
  .where('id', 'in', mySet) // breaks typings!
  .execute()

Which leads to having to write many .where('id', 'in', Array.from(mySet)) calls which could be avoided.

Best approach would be to allow all kinds of objects that extends Iterable<T, void, void> in parameters.

koskimas commented 3 weeks ago

They'd still get turned into arrays internally. It's better to be explicit.