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

feat(query): add translateAliases option to automatically call translate aliases on query fields #13397

Merged
merged 5 commits into from May 15, 2023

Conversation

vkarpov15
Copy link
Collaborator

Fix #7511
Fix #8678

Summary

Add translateAliases option on query, schema, and global level to apply Model.translateAliases() on all query fields automatically: filter, projection, update, and distinct.

Examples

Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

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

looks good to me, though there are some thing that should still be done:

  • test if the alias takes priority or errors if both are defined at the same time in the query
  • test if the alias has any effect if the alias is used in a query but the actual property in a update (or vise-versa)
  • document the above behavior somewhere on the documentation

also i dont know how feasible it is, but maybe consider calling _applyTranslateAliases in _optionsForExec?

lib/query.js Outdated Show resolved Hide resolved
Co-authored-by: hasezoey <hasezoey@gmail.com>
lib/query.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@AbdelrahmanHafez AbdelrahmanHafez left a comment

Choose a reason for hiding this comment

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

Got a couple of questions, but overall LGTM. Thanks! 👍

lib/query.js Outdated Show resolved Hide resolved
@vkarpov15 vkarpov15 merged commit ca84162 into 7.2 May 15, 2023
37 checks passed
@vkarpov15 vkarpov15 deleted the vkarpov15/gh-7511 branch May 16, 2023 01:08
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.

None yet

3 participants