BeanieODM / beanie

Asynchronous Python ODM for MongoDB
http://beanie-odm.dev/
Apache License 2.0
1.99k stars 211 forks source link

Pydantic "exclude" option is not working anymore #756

Open arielschvartz opened 10 months ago

arielschvartz commented 10 months ago

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.

gsakkis commented 10 months ago

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

roman-right commented 10 months ago

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.

arielschvartz commented 10 months ago

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 commented 9 months ago

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

roman-right commented 9 months ago

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.

TheBloke commented 6 months ago

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

mhdzumair commented 1 month ago

+1