6 ms·
I'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 includ
by blattimwind 8y ago
I'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).