Commited model.model_copy()
does not update the database accordingly
#1398
Unanswered
Pamplemousse
asked this question in
Questions
Replies: 1 comment
-
And these two tests are also failing 🤯 def test_hero_model_not_added_should_NOT_be_new_in_session(create_and_teardown_db_and_tables):
with Session(engine) as session:
new_name = "Super-Michel"
hero = Hero(id=1, name="Michel")
hero_copy = hero.model_copy(update={"name": new_name})
session.add(hero_copy)
assert not hero in session.new
def test_hero_model_added_should_be_new_in_session(create_and_teardown_db_and_tables):
with Session(engine) as session:
new_name = "Super-Michel"
hero = Hero(id=1, name="Michel")
hero_copy = hero.model_copy(update={"name": new_name})
session.add(hero_copy)
assert hero_copy in session.new |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
When using
pydantic
's methodmodel.model_copy()
to update fields, then trying tocommit
the resulting object to database, the record created there still has the old value for the updated field.Operating System
Linux
Operating System Details
No response
SQLModel Version
0.0.24
Python Version
3.13.3
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions