beanie icon indicating copy to clipboard operation
beanie copied to clipboard

Pydantic "exclude" option is not working anymore

Open arielschvartz opened this issue 2 years ago • 10 comments

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.

arielschvartz avatar Oct 20 '23 20:10 arielschvartz

I'm not sure which commit caused this but could you try if this PR happens to fix it?

gsakkis avatar Oct 20 '23 22:10 gsakkis

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.

roman-right avatar Nov 05 '23 21:11 roman-right

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.

arielschvartz avatar Nov 08 '23 23:11 arielschvartz

@gsakkis @roman-right Just to confirm, I've tested the new version 1.23.6 and still has the problem.

arielschvartz avatar Nov 20 '23 19:11 arielschvartz

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.

roman-right avatar Dec 04 '23 18:12 roman-right

Is there any ETA for this? I too want to use exclude to omit fields from Mongo

TheBloke avatar Feb 15 '24 22:02 TheBloke

+1

mhdzumair avatar Jul 14 '24 17:07 mhdzumair