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

[v3.4] Fix Taxon taxonomy id validation regression #5190

Conversation

RyanofWoods
Copy link
Contributor

@RyanofWoods RyanofWoods commented Jun 28, 2023

Summary

Fixes #5187.

In v3.4 I added optional Taxon validations which become mandatory in v4.0.
This caused a regression which made all root taxons with children always invalid.

Fix for v4:
#5189

This optional validation for root taxons (parent_id is nil), was
checking for uniqueness of taxonomy_id among all Taxons. This is wrong
however, as the children Taxons of this root Taxon will point to the
same Taxonomy. Instead, we should only look among other root Taxons.

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@github-actions github-actions bot added the changelog:solidus_core Changes to the solidus_core gem label Jun 28, 2023
@RyanofWoods RyanofWoods changed the base branch from main to v3.4 June 28, 2023 08:45
@kennyadsl kennyadsl added the type:bug Error, flaw or fault label Jun 28, 2023
@RyanofWoods RyanofWoods marked this pull request as ready for review June 28, 2023 09:15
@RyanofWoods RyanofWoods requested a review from a team as a code owner June 28, 2023 09:15
This optional validation for root taxons (parent_id is nil), was
checking for uniqueness of taxonomy_id among all Taxons. This is wrong
however, as the children Taxons of this root Taxon will point to the
same Taxonomy. Instead, we should only look among other root Taxons.
@RyanofWoods RyanofWoods force-pushed the ryanofwoods/3.4.0/fix-taxon-taxonomy_id-validation branch from 4f52cd9 to 2741efc Compare June 28, 2023 09:31
Copy link
Member

@elia elia left a comment

Choose a reason for hiding this comment

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

@RyanofWoods so if I understand correctly the if check deceived all of us because it looked like it was applied to the query, while it wasn't, right?

@RyanofWoods
Copy link
Contributor Author

Correct @elia, the if check may have caused some to think that only root Taxons are looked at for what taxonomy_ids are used. However, instead, it's only used to determine if this validation should be triggered or not. It doesn't affect the scope/query, and the uniqueness scope is needed for this.

I hope my explanations have been clear.

@kennyadsl kennyadsl merged commit 4961b6e into solidusio:v3.4 Jun 29, 2023
@kennyadsl kennyadsl deleted the ryanofwoods/3.4.0/fix-taxon-taxonomy_id-validation branch June 29, 2023 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:solidus_core Changes to the solidus_core gem type:bug Error, flaw or fault
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Root taxons with at least a child are not valid
3 participants