Skip to content

Validate order number uniqueness only when it changes#6493

Open
ikraamg wants to merge 1 commit into
solidusio:mainfrom
ikraamg:perf/order-number-uniqueness-on-change
Open

Validate order number uniqueness only when it changes#6493
ikraamg wants to merge 1 commit 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 89.69%. Comparing base (8d781ac) to head (3e6305d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6493   +/-   ##
=======================================
  Coverage   89.68%   89.69%           
=======================================
  Files         993      993           
  Lines       20863    20864    +1     
=======================================
+ Hits        18712    18713    +1     
  Misses       2151     2151           

☔ 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

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.

2 participants