Live data from Hacker News

Show HN: Kysely, a type-safe SQL query builder for TypeScript

kysely.dev

61–65 of 65 posts

Re: Show HN: Kysely, a type-safe SQL query builder for TypeScript

#61
post #23

If you want to run SQL, write SQL. The majority of your SQL will not require building dynamic where clauses or (dog forbid) dynamic joins. Having your SQL as plain statements with simple placeholders (to create safe prepared statements) is the saner approach. Not only can you pluck them into your favorite SQL tools and analyzers, but you will not be surprised by terribly performing queries, because you created them d…

In NodeJS land this library is pretty close to this: https://github.com/porsager/postgres

postgres.js is dope! I'm maintaining a Kysely community dialect for it. https://github.com/igalklebanov/kysely-postgres-js

Re: Show HN: Kysely, a type-safe SQL query builder for TypeScript

#62

I am building squashql-js for a slightly different use case (database agnostic SQL-like Typescript query builder among others) but Kysely and pypika (for Python) have been a great source of inspiration. https://github.com/squashql/squashql/blob/main/documentation...

Looks cool!

Kysely was inspired by Knex, but took a more predictable route instead of providing generic APIs that produce different SQL for different dialects. We believe that dialect "lock-in" should never be a real concern because migrating from let's say, MySQL to PostgreSQL is extremely rare in the real world.

Re: Show HN: Kysely, a type-safe SQL query builder for TypeScript

#63

For Java, JOOQ is great and offers better type safety than this. Additionally, JOOQ generates data model classes from the DB schema.

JOOQ is cool!

What do you mean by "better type safety"?

Kysely's ecosystem has 2 codegen libraries:

kysely-codegen introspects the database directly.

prisma-kysely generates types based on Prisma schemas.

Re: Show HN: Kysely, a type-safe SQL query builder for TypeScript

#64

I am building squashql-js for a slightly different use case (database agnostic SQL-like Typescript query builder among others) but Kysely and pypika (for Python) have been a great source of inspiration. https://github.com/squashql/squashql/blob/main/documentation...

Looks cool! Kysely was inspired by Knex, but took a more predictable route instead of providing generic APIs that produce different SQL for different dialects. We believe that dialect "lock-in" should never be a real concern because migrating from let's say, MySQL to PostgreSQL is extremely rare in the real world.

> MySQL to PostgreSQL is extremely rare in the real world.

That's true, I agree.

But we are mainly targeting software editors that build data analytics platform and let their customers choose where they want to store their data and run their analysis (on premise, in the cloud). Having a common API avoid adapting developed applications for each customer.

Re: Show HN: Kysely, a type-safe SQL query builder for TypeScript

#65
post #57

Have used it for a smaller project for a bit now and I really like it as well. Concise code and I can still map it to actual SQL in my brain. What has been a bit non-intuitive for me though is the expression builder since the latest major version of kysely. When writing queries with `OR` conditions it always takes me a while to wrap my head around it again. It is also challening to make this easily readable with lots…

Would love to have a discussion about your use case in our discord. We're constantly thinking about improving that part of our API as it's at the heart of many things.

Sure, I'll reach out
Post reply on HN