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

🐞 fix: implement normalization support for class instances with getter functions #718

Merged
merged 2 commits into from
Jul 23, 2024

Conversation

m1212e
Copy link
Contributor

@m1212e m1212e commented Jul 15, 2024

When returning class instances which use getter functions, normalization does not work in stripping those fields. Typeboxes Clean does not remove getter instances on objects in certain scenarios. This came to my mind because the prisma ORM uses this when defining extensions resulting in the inability to return database query outputs directly. My PR adjusts the clean call to traverse the prototype tree of a passed object, gathering all values located behind a get call and merging them with the original value. It does so in a performance sensitive manner, I check if the operations are required before blindly applying them.

Would be great if you could take a look @SaltyAom and I'd be happy to receive feedback/make any necessary changes. Thanks for your work!

@m1212e
Copy link
Contributor Author

m1212e commented Jul 15, 2024

sinclairzx81/typebox#842

@SaltyAom SaltyAom merged commit a56976b into elysiajs:main Jul 23, 2024
1 check passed
@m1212e m1212e deleted the normalization-getter-fields-fix branch July 23, 2024 17:22
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

2 participants