Propose change for subclass inherited_fields override when include_fk=False #657
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi again, hope all is well.
This is sorta an addendum to #440.
I was running into an issue when upgrading my marshmallow-sqlalchemy version to 1.3 on a project because of the PR on the above report.
The existing tests seem to work because
get_declared_fields
inmarshmallow/schema.py
concatenates inherited_fields with class_fields. However, when trying to extend an AutoSchema with a marshmallow.schema.Schema to override a FK field, the new_maybe_filter_foreign_keys
filters these fields out as well. I provided a test case in the PR to explain what I mean.The way I thought to overcome this problem is by differentiating between the types of inheritance by some discriminator. I tried when fields are inherited from a Schema that is not a SQLAlchemySchema, the motivation being that SQLAlchemyAutoSchema introduces the include_fk field and the inheritance/overriding of this field is the nexus of the entire issue. I'm not sure if this is the best solution, but does work for the case that brought this issue to my attention and the existing test suite.
I'm open to any thoughts or suggestions. Thanks for all of your work!