Replies: 1 comment 6 replies
-
Yes, But you cannot change this in ormar as of now, that can be a possible enhancement. It was not supported from the beginning as there is no way to persist this randomly added column in a database anyway. And since ormar heavily operates on its own set of fields (among others to include proper relation handling etc.), it would have to reach to pydantic to check if there are any additional fields which I wanted to avoid. But that refers only to accepting the newly created fields, a setting for Why are you passing empty dict value anyway? :) |
Beta Was this translation helpful? Give feedback.
-
Hi!
I've been trying to set up a demo app to get familiar with ormar - everything has been going very good so far, so thanks a lot for creating this 👏
I just ran into something confusing that I'm not sure is a bug or intended behaviour:
Issue
when sending in an empty field name (
"": None
} in a request body, ormar from here raises aModelError
which results in a 500 being returned from my endpoint.Context
This happens in my update endpoint (but I think it would happen anywhere), which looks like this:
The payload that triggers the error looks like this
And my model looks like this:
Expected behavior
I would expect Ormar to ignore this empty field value since it doesn't correspond to anything in my model. Alternatively I would like the
ModelError
to result in a 422 being returned - anything other than a 500, since this would mean I have to add logic for this in every endpoint.If I substitute the Ormar model with a Pydantic model, Pydantic seems to just ignore the field. This works:
Is this a bug, or am I missing something important in terms of how to structure my APIs? 🙂
Beta Was this translation helpful? Give feedback.
All reactions