Issue warning when map_entry can't find field for query #183
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.
While working on
map_query
, I realized a shortcoming of the field/name mapping in the inheritance case.In the framework tests, we use the parent class to find a child element based on a query on a field that does not exist in the parent class.
It works, but I believe it is wrong. The query mapper does not have access to the field, so it can not do its job. In fact the query will fail if the field is an
EmbeddedField
(I could reproduce that) because inmap_entry
we won't pass in the dedicated case asfield
isNone
:I don't think we can pass the child classes fields here, and it would be a bad idea because different children could have different fields for the same name, so the field is undefined.
Since it works in some (in fact, most) cases anyway, I propose to just add a non-breaking warning at least for now. But I can make this an
Exception
. Or if we plan to forbid this in the next major version, I can use aDeprecationWarning
.Or do we want users to be able to pass query entries that don't match a field known to the model?
This is a corner case, but since the wrong use was shown in the tests, users may be relying on it.
I can review the warning/exception type, the message string (add a note about inheritance ?), and perhaps rework the framework tests to isolate this specific test.
Feedback welcome.