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 translations junction field not using language table name #12461

Merged
merged 1 commit into from Mar 29, 2022

Conversation

azrikahar
Copy link
Contributor

Fixes #12255

Before

Whenever we change the language table name during creation of Translations field, the junction field always remains as languages_id instead:

chrome_Rp1tPvbnPl.mp4

Solution used

For m2m, whenever relation.m2o.related_collection has changed, it will call the autoGenerateJunctionFields function:

if (hasChanged('relations.m2o.related_collection')) {
preventCircularConstraint(updates, state, helperFn);
autoGenerateJunctionFields(updates, state, helperFn);
}

which then always updates the junction field name:

set(updates, 'relations.m2o.field', `${relatedCollection}_${relatedPrimaryKeyField}`);

Hence this solution uses a similar logic with updateJunctionRelated function to update said field.

After

chrome_7svCIjbDzj.mp4

@rijkvanzanten rijkvanzanten added this to the v9-next milestone Mar 29, 2022
@rijkvanzanten rijkvanzanten merged commit 8f0fa7b into main Mar 29, 2022
@rijkvanzanten rijkvanzanten deleted the issue/12255 branch March 29, 2022 13:39
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Language table foreign key name does not correspond with language table name
2 participants