Live data from Hacker News

Sqlc: Data access simplified. Throw away your ORM

docs.sqlc.dev

1–10 of 24 posts

Re: Sqlc: Data access simplified. Throw away your ORM

#3
Numbered parameters become fragile quite fast for even simple queries. Basically you couldn't safely use query until carefully revising a template. A template change could potentially break existing queries. It's kinda scary.

If library supports named parameters they should be used by default in examples.

Re: Sqlc: Data access simplified. Throw away your ORM

#4
Static templates for SQL becomes a chore to express dynamic queries. A dynamic query depends from incoming request. For example search filters should add or delete conditional expressions for a query.

I have a little research[1] on dynamic queries.

[1]: https://github.com/baverman/sqlbind?tab=readme-ov-file#dynam...

Re: Sqlc: Data access simplified. Throw away your ORM

#6
post #4

Static templates for SQL becomes a chore to express dynamic queries. A dynamic query depends from incoming request. For example search filters should add or delete conditional expressions for a query. I have a little research[1] on dynamic queries. [1]: https://github.com/baverman/sqlbind?tab=readme-ov-file#dynam...

If you're writing a lot of dynamic queries I think you should opt for a query builder, not an orm.

For me, I write almost nothing but static queries, SQLc is just so much nicer to use.

I don't mind having to do the odd dynamic query from scratch.

I just wish sqlc supported named Params in MySQL, the resulting function param ordering is a little annoying.

Re: Sqlc: Data access simplified. Throw away your ORM

#10
post #4

Static templates for SQL becomes a chore to express dynamic queries. A dynamic query depends from incoming request. For example search filters should add or delete conditional expressions for a query. I have a little research[1] on dynamic queries. [1]: https://github.com/baverman/sqlbind?tab=readme-ov-file#dynam...

If you're writing a lot of dynamic queries I think you should opt for a query builder, not an orm. For me, I write almost nothing but static queries, SQLc is just so much nicer to use. I don't mind having to do the odd dynamic query from scratch. I just wish sqlc supported named Params in MySQL, the resulting function param ordering is a little annoying.

The issue with templates they could handle only simple cases or very specific complex static queries. Simple ones are a way easier with ORM/query builder. Highly depends from ORM though.

And a big NO-NO for me templates force you to repeat the same SQL in many slightly different queries. SQL composability is not a thing with templates.

Post reply on HN