dymmond / edgy

🔥 The perfect ORM to work with complex databases 🔥
https://edgy.dymmond.com
BSD 3-Clause "New" or "Revised" License
193 stars 9 forks source link

ManyToMany's Related Manager is not provided on object #101

Closed devkral closed 2 months ago

devkral commented 5 months ago

Discussed in https://github.com/tarsil/edgy/discussions/98

Originally posted by **edimedia** May 25, 2024 Hi ! I think the related manager is not provided on object when this one is retrieved from DB, look at this: models.py db, registry = get_db_connection() class World(Model): id = fields.IntegerField(primary_key=True) name = fields.CharField(max_length=255) class Meta: registry = registry class Hello(Model): id = fields.IntegerField(primary_key=True) name = fields.CharField(max_length=255) worlds = fields.ManyToManyField(World, related_name="hellos") class Meta: registry = registry test_many2many_create.py world = await World.query.create(name='Hearth') hello = await Hello.query.create(name='King') await hello.worlds.add(world) # It works correctly test_many2many_retrieve.py h = await Hello.query.get(id=1) w = await World.query.get(id=1) await h.worlds.remove(w) # AttributeError: 'NoneType' object has no attribute 'remove' And when i'm looking for a sample code in `edgy/tests/foreign_keys/test_many_to_many.py`, i see there's no test about retrieve (get or filter method). Thank you.
devkral commented 5 months ago

should be fixed now. Try the release branch if it is still a problem.

devkral commented 5 months ago

Ping?

tarsil commented 5 months ago

@devkral the release branch no longer exists, he should try the main

devkral commented 2 months ago

Can I close? I think the issue is resolved.