-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deserializing a multiple nested dictionary while abiding unique constraints on foreign key tables #455
Comments
I suspect this behavior would be generally useful:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have the following SQLAlchemy Models:
I went ahead and created the corresponding Marshmallow schemas:
I would ideally like to be able to add the following dictionary to the database, without adding a new task to the
ToDoTask
table if it already exists (hence theunique=True
constraint on the model).When trying to use the Marshmallow
.load()
method, I run into the error that the data cannot be added due to the unique constraint because dictionary already includes that value. I would like to only add the corresponding foreign key to the to ToDo table instead.Given the following code:
I am getting an integrity error here because of the unique constraint on the ToDoTask.task column although I want Marshmallow to recognize the value already exists and only fetch it's ID and enter it in the ToDo table under task_id.
If the
ToDoTask
table contains 1 row with task equal to "Gym", I would like to populate theUser
table with theemail="[email protected]"
,password="test"
and then theToDo
table withuser_id=2
,task_id=1
Here is the link on SO if anyone is interested: https://stackoverflow.com/questions/73335484/how-to-deserialize-a-multiple-nested-dictionary-using-marshmallow-while-abiding
The text was updated successfully, but these errors were encountered: