Skip to content

Fix ModelSchema ignoring declared fields when using exclude#1631

Open
almazkun wants to merge 1 commit intovitalik:masterfrom
almazkun:master
Open

Fix ModelSchema ignoring declared fields when using exclude#1631
almazkun wants to merge 1 commit intovitalik:masterfrom
almazkun:master

Conversation

@almazkun
Copy link
Copy Markdown

Closes: #1630

Comment thread ninja/orm/factory.py

def _get_declared_fields(self, base_class: Type[Schema]) -> Set[str]:
# Extracts field names already declared in the base Schema class to prevent duplicates when generating model fields.
if not hasattr(self, "_annotation_cache"):
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @almazkun

is there a reason to cache declared fields here with _annotation_cache ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vitalik No real reason, just trying to skip the field check each time because it seems the schema is walked multiple times when it’s built.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] ModelSchema excludes declared fields when using exclude but not when using fields

2 participants