Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I get that, and I'm comfortable writing raw SQL but as the system grows larger and requirements change I inevitably run into the fact that raw SQL doesn't compose. For me the query builders hit that sweet spot of mapping almost one-to-one to raw SQL, while giving me composition when I need it.


99% of the time you should'be be composing SQL.

If you need composition at the DB level, that is what Views are for.


I'm not sure why you think we shouldn't be composing SQL. What about for cases like:

User.banned.posts.flagged where we want all flagged posts from banned users.

Posts.flagged.today where we want all flagged posts from today

User.created_today.posts.flagged where we want all flagged posts from users created today


Or you could just create a View for flagged posts and join on that as appropriate, no ORM needed.

There's probably some room for limited compositional SQL, but there are ways to get that without a full ORM, given your type system is expressive enough.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: