▲ | williamdclt a day ago | ||||||||||||||||||||||||||||||||||
I'm finding all these SQL builders so painful to use. They closely match the syntax of SQL so you do need to know SQL, but now you also need to know the SQL builder's syntax. It's friction for juniorer devs to learn SQL. It's also now much more difficult to trace a SQL query back to the originating code. They have two advantages: building SQL statements programmatically is cleaner than string concatenation, and they allow typing inference. The former is not so often necessary (and even when it is, it's often simple enough that string concatenation is _alright_). The latter is what makes me hesitate as a typing ayatollah, but even then I don't think it's worth it (I'll take the explicit typing, with the risk that we get it wrong, which would likely-although-not-surely be caught in tests). I still need something for migrations and query execution, but I would only reach for query building in like 1% of cases. | |||||||||||||||||||||||||||||||||||
▲ | ajfriend a day ago | parent | next [-] | ||||||||||||||||||||||||||||||||||
One approach I've been enjoying recently in my personal use is to write a light wrapper around DuckDB to enable composable SQL snippets. Essentially like what I have here https://gist.github.com/ajfriend/eea0795546c7c44f1c24ab0560a..., but without the `|` syntax. You're still writing SQL, so you don't need to learn a new syntax, but I find it more ergonomic for quick data exploration. I also have an easier time writing SQL from memory than I do writing the equivalent Pandas code. | |||||||||||||||||||||||||||||||||||
▲ | bearjaws a day ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||
> They closely match the syntax of SQL so you do need to know SQL, but now you also need to know the SQL builder's syntax. I tend to agree, I recently tried Slonik and found it fun to use, but when I tried to incroporate it into an existing project I ran into ESM / TS issues (even with interop on, annoyingly). I also want to give pg-typed a try. The only reason I would recommend it is I feel many systems tend to have some sort of dynamic query builder "UI" over time, especially in enterprise spaces, and a query builder solves these problems very well. | |||||||||||||||||||||||||||||||||||
▲ | thrw42A8N a day ago | parent | prev [-] | ||||||||||||||||||||||||||||||||||
I have never had any issues like this, and the type safety provided by Kysely has saved me a lot of bugs and potentially very serious issues. | |||||||||||||||||||||||||||||||||||
|