top | item 36419202

(no title)

paraph1n | 2 years ago

How does it compare to zapatos?

https://jawj.github.io/zapatos/

discuss

order

lf-non|2 years ago

We moved away from zapatos because the generated types are good only when selecting from single table. The moment we start selecting some subset of columns from a join of multiple tables, it is upto the developer to provide the right combination of pick and intersection of generated types and type safety takes a hit.

The solution we use right now is ts-sql-query [1] which supports automatic type-safety for complex joins, CTEs, subselects etc. I evaluated Kysely as well but found the sql feature set coverage of ts-sql-query better at the time.

I maintain a code-generator [2] for this project that can generate the table mappers from database schema similar to how zapatos.

We don't have as good support for lateral joins and deriving json from database though, which zapatos does really well.

[1] https://ts-sql-query.readthedocs.io/

[2] https://github.com/lorefnon/ts-sql-codegen

igalklebanov|2 years ago

> which supports automatic type-safety for complex joins, CTEs, subselects etc. I evaluated Kysely as well but found the sql feature set coverage of ts-sql-query better at the time.

Kysely also provides "automatic type-safety for complex joins, CTEs, subselects etc.".

Gotta love how toxic some open-source maintainers are, bashing other libraries while self-promoting.

igalklebanov|2 years ago

I'd suggest you try them both, and pick what you like better or what feels safer to bet on for your project.

I know some of our users use both, zapatos for codegen and kysely for querying.