You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an issue with my data structure. Not sure if it's a bug, or (more probably), something that could be solved by tweaking the shema.
I have two objects, let's call them A and B, and an assotiation object A_to_B with a quantity.
This association object's primary key is composed of the foreign keys of A and B
We receive data as nested : A containing A_to_B containing B :
"a" : {
"id": a_id,
// other A data
b_data: {
quantity: 1,
b: {
"id": b_id,
// B data
}
}
The first time I load the data, everything works fine.
But the issue is that when trying to re-load existing data, sqlalchemy tries to delete the existing A_to_B (and to recreate it afterward).
It seems for some reason, marshmallow-sqlalchemy doesn't realize the association object is the same than the one that exists in the base.
Also at time of merge, sqlalchemy doesn't realize either, and removes the old instance to re-create the same thing.
For now the association schema looks like this :
class AToBSchema(BaseSchema):
b = Nested(BSchema)
class Meta(BaseSchema.Meta):
model = AToB
Any idea to prevent this unnecessary new instance ? (with a deletion of the old one)
The text was updated successfully, but these errors were encountered:
Hi,
I have an issue with my data structure. Not sure if it's a bug, or (more probably), something that could be solved by tweaking the shema.
I have two objects, let's call them A and B, and an assotiation object A_to_B with a quantity.
This association object's primary key is composed of the foreign keys of A and B
We receive data as nested : A containing A_to_B containing B :
The first time I load the data, everything works fine.
But the issue is that when trying to re-load existing data, sqlalchemy tries to delete the existing A_to_B (and to recreate it afterward).
It seems for some reason, marshmallow-sqlalchemy doesn't realize the association object is the same than the one that exists in the base.
Also at time of merge, sqlalchemy doesn't realize either, and removes the old instance to re-create the same thing.
For now the association schema looks like this :
Any idea to prevent this unnecessary new instance ? (with a deletion of the old one)
The text was updated successfully, but these errors were encountered: