Saving related model broke in latest release
See original GitHub issueI have a test that started failing after I updated to the latest 0.7.0 release.
c = await domain.Category(name="Foo", code=123).save()
ws = await domain.Workshop(topic="Topic 1", category=c).save()
assert ws.id == 1
assert ws.topic == "Topic 1"
assert ws.category.name == "Foo"
Simple test, and the error is
E AssertionError: assert None == 'Foo'
E +None
E -'Foo'
I can see that the category gets saved and is also saved in the database for the workshop, but it’s not updated in the model correctly. In the ws.category
I see only the id
column, and saved = False
.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Saving Your Data - 2.x - CakePHP Cookbook
When working with associated models, it is important to realize that saving model data should always be done by the corresponding CakePHP model....
Read more >Calling `$model->save()` does not work if the `$model` object ...
The User model that is returned is basically a new instance with a 'name' property. It's not the actual instance representing that row...
Read more >how to override django save method to update some field ...
Solution One: I think instead of changing in Ledger model, you should change in Expense model, like this: class Expense(models.
Read more >[FNV] New Vegas Save Related Issues Help Thread - Reddit
Is a common issue with certain save methods in New Vegas. Will often manifest itself as broken quests, infinite loading screens/crash on ...
Read more >Split and Save Bodies - 2022 - SOLIDWORKS Help
This enables you to save the bodies from a split part to a different folder or with different names to the same folder....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
OK,
I wanted to make sure that pre-save signal receive the model with populated defaults and overdid it, sorry 😃
Should be fixed in 0.7.1.
Btw. When you want pytest fixture to run only once for whole module (like db creation) you cen set
scope=module
option in fixture decoratorThat way you don’t have to pass the fixture around to test functions.
Also now you run against sqlite but if you intend to run against mysql or postgress you need to actually explicitly connect in test - best as a context manager with nomen omen
with
😉It does not affect sqlite buf fixes test for other backends.
This passes for me:
So let me know if you still have the same problem.