Pydantic "exclude" option is not working anymore
Describe the bug After upgrading from version 1.22.6 to version 1.23.0, pydantic property exclude stopped working.
Expected behavior I have a user model which have email and password and I don't want to save the password to mongo. I have the following model:
class UserCreate(User):
"""All fields needed to create a user"""
password: Optional[str] = pydantic.Field(
description="A user's password in plain text before it has been hashed",
exclude=True,
)
I expected the password not to be saved into the database but after upgrading versions it is saving it.
I'm not sure which commit caused this but could you try if this PR happens to fix it?
Hi @arielschvartz, Thank you for catching that. Did you get a chance to check what @gsakkis asked? I'll address this during the next bug-fixing session next week.
Hi there @gsakkis and @roman-right . Sorry for the delay here.
I have not tested specifically this PR, but I tested upgrading to 1.23.1 (as I understood the PR was merged). Unfortunately, it still doesn't look it was fixed. I can do some more specific testing next week if needed.
@gsakkis @roman-right Just to confirm, I've tested the new version 1.23.6 and still has the problem.
Confirmed. Currently there is a conflict with another part, as exclude is used to hide fields in FastAPI outputs.
I'll redesign this and add this to the documentation.
Is there any ETA for this? I too want to use exclude to omit fields from Mongo
+1