Skip to content

Validate order number uniqueness only when it changes#6493

Merged
jarednorman merged 2 commits into
solidusio:mainfrom
ikraamg:perf/order-number-uniqueness-on-change
Jul 17, 2026
Merged

Validate order number uniqueness only when it changes#6493
jarednorman merged 2 commits into
solidusio:mainfrom
ikraamg:perf/order-number-uniqueness-on-change

Conversation

@ikraamg

@ikraamg ikraamg commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Solidus validates number uniqueness on every order save. The validation passes case_sensitive: true, which opts out of Rails' built-in skip for unchanged values, so the uniqueness query runs on every save, including each order recalculation.

This gates the uniqueness validation on number_changed? so it only runs on create and when the number changes.

  • order recalculation drops from 4 queries to 2
  • uniqueness is still enforced for new orders and for number changes
  • adds specs covering both the enforcement and the skip

The number uniqueness check ran on every order save because case_sensitive: true opts out of Rails' built-in unchanged-value skip, adding a redundant query to each recalculation. Gating the validation on number_changed? runs it only on create and when the number actually changes.
@github-actions github-actions Bot added the changelog:solidus_core Changes to the solidus_core gem label Jun 25, 2026
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.02%. Comparing base (7b576fe) to head (a84c051).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6493   +/-   ##
=======================================
  Coverage   92.02%   92.02%           
=======================================
  Files        1035     1035           
  Lines       21129    21130    +1     
=======================================
+ Hits        19444    19445    +1     
  Misses       1685     1685           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ikraamg
ikraamg marked this pull request as ready for review June 26, 2026 06:33
@ikraamg
ikraamg requested a review from a team as a code owner June 26, 2026 06:33

@tvdeyen tvdeyen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice. Thank you

@jarednorman
jarednorman enabled auto-merge July 17, 2026 19:00
@jarednorman
jarednorman merged commit d4463ad into solidusio:main Jul 17, 2026
38 of 39 checks passed
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants