Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pydantic "exclude" option is not working anymore #756

Open
arielschvartz opened this issue Oct 20, 2023 · 6 comments
Open

Pydantic "exclude" option is not working anymore #756

arielschvartz opened this issue Oct 20, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@arielschvartz
Copy link

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
Copy link
Contributor

gsakkis commented Oct 20, 2023

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

@roman-right
Copy link
Member

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
Copy link
Author

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
Copy link
Author

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

@roman-right roman-right added the bug Something isn't working label Dec 4, 2023
@roman-right
Copy link
Member

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants