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(types): override types deep merge #605

Merged
merged 2 commits into from
Feb 21, 2025

Conversation

avallete
Copy link
Member

@avallete avallete commented Feb 21, 2025

Upgrading supabase-js and trying things out in our own repository, I spotted some bugs with the way the merging was done for some cases notably:

  1. The properties weren't properly overwrote by the new value if it existed in the original ( that's on me for not writing this basic test 😓)
  2. If we wanted to override a "nullable object" such as one within a json field, it wasn't possible to do so without re-writing the whole object, instead of just the property we wanted. This has been changed and now we'll deep-merge and rely on the new casted type to know if we must preserve the optionality or not.
  3. Related to 2 but for relations (such as inner) or embeded arrays relationships, it wasn't possible to override the type of one property in the embeded tables. This is now possible by checking if both old and new values property are arrays, and if that's the case, merging the type of those arrays togethers. Otherwise, the new value will take over and replace the old one.

- Allow to deep-merge arrays for relations embeding
- Fix issue not replacing existing property
- Allow to deep-merge nullables objects for innerjoin and JSON override
@avallete avallete merged commit 9b2c8fc into master Feb 21, 2025
2 checks passed
Copy link

🎉 This PR is included in version 1.19.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants