News for hackers. Stuff that matters.
Re:Django 3.2 by NeutralForest on Tuesday April 06, 2021 @10:48AM (#26712436)
I haven't used Django except as an ORM and it was a terrible experience. Anytime I wanted to update an existing relationship, it was a pain. I've heard a lot of good stuff about it when used as a web framework but I was really baffled by the ORM.
Re:Django 3.2 by ph4 on Tuesday April 06, 2021 @11:37AM (#26713157)
What was so painful about it? Unless you're making some really significant changes to your models, Django's migration commands handle 99.9% of cases including most common edge cases. I can't imagine it being any easier, and certainly haven't seen any other web frameworks handling migrations any better.
Re:Django 3.2 by NeutralForest on Tuesday April 06, 2021 @01:57PM (#26715159)
I just tried to add a new attribute to a many-to-many relationships
Re:Django 3.2 by Syntaf on Tuesday April 06, 2021 @11:38AM (#26713173)
I've found the Django ORM to be, in my own opinion, one of the easiest ORMs to hit the ground running with. What was the confusing aspect of updating relational data for you?
Re:Django 3.2 by NeutralForest on Tuesday April 06, 2021 @02:06PM (#26715249)
Creating relationships was not a problem but for example, adding new fields to an already created many-2-many was an issue. Changing migration scripts was also a hassle.
Re:Django 3.2 by skrtskrt on Tuesday April 06, 2021 @04:20PM (#26716884)
I have run into this exact problem. A many-to-many table had a business meaning, not just an "invisible" relationship. We wanted to put a model in front of it & add soft deletes and created-at/updated-at fields, at it was a mess of hoops and hacks to jump through.
Re:Django 3.2 by rrmm on Tuesday April 06, 2021 @05:36PM (#26717678)
Does this go easier in any other ORM/DBs that you might have used? Sounds like the semantics of the real-world stuff didn't quite match up to the DB semantics.
Re:Django 3.2 by skrtskrt on Thursday April 08, 2021 @12:19PM (#26740635)
We rolled a simple repository pattern library that fit over the SQLAlchemy Table API (no ORM objects, only tables).

Actually writing the the tables was very freeing, no more separation and surprises in the translation between a single model and the multiple tables it can create.

For each new object, we wrote a SQLAlchemy Table object, a domain entity object, and optionally an adapter if you need to map field names between the two. The 300 lines of repo library code did the rest.

A little boilerplate, but no need for a ton of impenetrable, hyper-dynamic ORM code.

Alembic can autogenerate migrations from the SQLALchemy Table objects