I'm experiencing an issue with nested models.
Here is my POST JSON:
{ "name": "some string value", "tag": { "tag_id": 5, "value": null } }
"name": "some string value",
is in TableA
"tag": { "tag_id": 5, "value": null }
is in TableB and it has a reference to TableA
`_data = data.model_dump(exclude_unset=True, by_alias=False, exclude_none=True)
get json element as a class
tag: MetaDataTagValue = _data.pop('tag')
saved_line: MetaDataLine = await meta_data_line_repo.add(MetaDataLine(**_data))
await meta_data_line_repo.session.commit()
add foreign key of the record that was just saved
tag.update({'line_id': saved_line.id})
everything is fine up until the next line with '.add(**tag)'
saved_tag: MetaDataTagValue = await meta_data_tag_value_repo.add(**tag)
await meta_data_tag_value_repo.session.commit()`
I get the following error message
"detail": "SQLAlchemyAsyncRepository.add() got an unexpected keyword argument 'tag_id'"
However, tag_id is part of the MetaDataTagValue structure.
I know that I doing something incorrectly, but I do not know what.
Can you help me out or maybe point me in the correct direction?
I can post a link to my GitHub with all of this, plus more if you'd like.
Side Note:
This has been an ongoing issue for me for the last two weeks or so and I've tried many different things, sometimes ending up with an error message saying something like "dict does not have a sa_attribite".