▲ | webstrand 3 days ago | ||||||||||||||||
It sounds like you're describing a query builders which, unlike true ORMs, don't attempt to mask the object-relational boundary. They only help you build queries in a convenient way and sometimes type-safe way. Query builders are great. ORMs are not query builders. The problem with ORMs is that they hide the query logic from you. It's not clear what's getting joined in, how its getting joined in, or if its actually 1 or N queries. The further you get from a straight query builder, too, the fewer SQL features you have access to, such as parameterized joins, CTEs, window functions, etc. Sometimes you can hack those into the ORM, but often you have to resort to string concat and build the parameterized query and arguments manually. I've never used Exposed, but from what I can tell it's kind of a hybrid? the query builder parts look great, but I'd still be wary of the ORM parts. I've never had a good experience debugging performance issues in ORM-generated queries. Maybe I haven't used the right ones, but the libraries I've used have gone out of their way to hide how the query is actually being executed and only have obtuse levers to tweak that execution. Sure you can see the raw logs of what queries the ORM executed, but you can't easily figure out why its chosen a particular strategy. Or you can't easily make it stop using a pathological join ordering. | |||||||||||||||||
▲ | prmph 3 days ago | parent | next [-] | ||||||||||||||||
If one can update the underlying Db, I've developed an ORM pattern that I use in my projects that works very well. They keys is to encapsulate most of the (possibly complex) CRUD logic in Db functions (for retrieval these would be table-valued functions) and access these from the application side as virtual tables. I also have capable but easy to use filtering/sorting/paging operators and combinators in the ORM that are translated into SQL where/sort/limit clauses. Because the heavy lifting is already done by the db functions (which you have full control of to use whatever SQL you need), the pattern is actually quite powerful but easy to use. You can define virtual read only tables, several virtual tables that access the same actual table in different way, custom operators that transcend SQL, etc | |||||||||||||||||
| |||||||||||||||||
▲ | andoando 3 days ago | parent | prev [-] | ||||||||||||||||
I HATE ORMs. I end up spending an hour or two trying to figure out why something isnt working for what should be a simple query. Theyre also seem quite restrictive to what raw sql can do. | |||||||||||||||||
|