3 ms·
I've worked on large projects using ORMs and others using parameterised SQL strings. My experience, FWIW, is that the advantages listed in the article are all r
by tragic 8y ago
I've worked on large projects using ORMs and others using parameterised SQL strings. My experience, FWIW, is that the advantages listed in the article are all real, on top of which there are some more esoteric SQL features (like window functions) that may not be well supported by a given ORM.
On the other hand, there is a significant cost in terms of duplication. In ORM code it is trivial to decide a where clause at run time. Not so much in plain SQL. So you end up with a lot of copies of the same query, or else some sort of query assembly layer, at which point you're halfway to an ORM anyway. I am undecided on the issue.
- blattimwind 8y agoI'm convinced there are two classes of ORMs. Those that try to abstract the relational model and those who are the relational model. The former category includes things like Django's ORM: very limited in what you can do, it doesn't actually "get" SQL, mismatch between the ORM API and the database. The latter category includes fewer software; sqlalchemy is my familiar example. Because sqlalchemy does not abstract the relational model, instead mapping it into your application language, it has ~few mismatches between its API and the database. The former category is what "kinda works well enough for CRUD apps and I don't need to know anything about nothing" and then become a major problem, the latter category presumes you know how SQL works but then allows you to work. Random snippet just because I feel like it. def all_children(self): cte = session.query(Tag).filter(Tag.parentid == self.tagid).cte(recursive=True) cte = cte.union_all(session.query(Tag).filter(Tag.parentid == cte.c.tagid)) return session.query(Tag).select_entity_from(cte).all()
- mst 8y agoI tend to refer to the latter as ROMs. Ruby's Sequel is also somewhat this. My (perl5) DBIx::Class is somewhat this (modulo all the design mistakes).