-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: support casting of nested properties #252
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…n without casting
…n without casting
0604185
to
dd36cf2
Compare
danibix95
reviewed
Jan 25, 2024
…ub.com/mia-platform/crud-service into fix/cast-of-nested-properties-from-v6x
danibix95
approved these changes
Jan 25, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pull Request Type
Description
This feature extend the support for casting values also for properties included in nested fields.
E.g., the query
{ 'obj.numericValue': '5' }
will be translated to{ 'obj.numericValue': 5 }
if the collection definition includes the fieldnumericValue
and defines it a as a string.To achieve this, the method
getFieldDefinition
have been improved to be recursive and recursive an object where the key will be the path of the nested field (the value will be its type - as defined in the colleciton definition). This function has been to a separate file (QueryParser.utils.js
) for readibility. Tests have been included in a separate file (queryParser.utils.test.js
).Also, the function
QueryParser.js#traverse
has been refactored to improve clarity and handle correctly the case of nested fields.In case a field of type object/array does not define its children fields, casting will not be applied but the query will work nonetheless. This causes also to allow queries using the dot notation (e.g.
{ 'obj.numericValue': 5 }
) to be valid even if the field might not exist because of the schema (this might be different related to the previous behavior of the application since it was more strict in this sense).PR Checklist
Does this PR introduce a breaking change?
Other information