-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix(ui): copyToLocale should not pass any id's to avoid duplicates #11887
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(ui): copyToLocale should not pass any id's to avoid duplicates #11887
Conversation
Is there a chance that someone could look into whether this can be merged into one of the next releases? We would love to see a solution to the underlying issue. Thank you in advance! |
909db87
to
08ed1ee
Compare
Well, i got desperate - so i have now published the fork including the fix, so if anyone else wants this feature before payload merges it, feel free to use the following in your |
This bug basically renders the copy function useless when using block fields. |
@Bjornnyborg thank you for your work on this - and thanks everyone for your patience. I am reviewing now and aim to get the fix merged ASAP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks good and works as expected. I added a test for this issue and a minor change to the removeIds
function. Thanks again @Bjornnyborg 🥇
@jessrynkar Thank you for looking into this 👍 |
🚀 This is included in version v3.36.0 |
…11887) ### What? Using the `Copy To Locale` function causes validation errors on content with `id` fields in postgres, since these should be unique. ``` key not found: error:valueMustBeUnique key not found: error:followingFieldsInvalid [13:11:29] ERROR: There was an error copying data from "en" to "de" err: { "type": "ValidationError", "message": "error:followingFieldsInvalid id", "stack": ValidationError: error:followingFieldsInvalid id ``` ### Why? In `packages/ui/src/utilities/copyDataFromLocale.ts` we are passing all data from `fromLocaleData` including the `id` fields, which causes duplicates on fields with unique id's like `Blocks` and `Arrays`. ### How? To resolve this i implemented a function that recursively remove any `id` field on the passed data. ### Fixes - #10684 - https://discord.com/channels/967097582721572934/1351497930984521800 --------- Co-authored-by: Jessica Chowdhury <[email protected]>
…11887) ### What? Using the `Copy To Locale` function causes validation errors on content with `id` fields in postgres, since these should be unique. ``` key not found: error:valueMustBeUnique key not found: error:followingFieldsInvalid [13:11:29] ERROR: There was an error copying data from "en" to "de" err: { "type": "ValidationError", "message": "error:followingFieldsInvalid id", "stack": ValidationError: error:followingFieldsInvalid id ``` ### Why? In `packages/ui/src/utilities/copyDataFromLocale.ts` we are passing all data from `fromLocaleData` including the `id` fields, which causes duplicates on fields with unique id's like `Blocks` and `Arrays`. ### How? To resolve this i implemented a function that recursively remove any `id` field on the passed data. ### Fixes - #10684 - https://discord.com/channels/967097582721572934/1351497930984521800 --------- Co-authored-by: Jessica Chowdhury <[email protected]>
What?
Using the
Copy To Locale
function causes validation errors on content withid
fields in postgres, since these should be unique.Why?
In
packages/ui/src/utilities/copyDataFromLocale.ts
we are passing all data fromfromLocaleData
including theid
fields, which causes duplicates on fields with unique id's likeBlocks
andArrays
.How?
To resolve this i implemented a function that recursively remove any
id
field on the passed data.Fixes