Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6400 +/- ##
==========================================
+ Coverage 89.48% 89.49% +0.01%
==========================================
Files 980 981 +1
Lines 20438 20458 +20
==========================================
+ Hits 18289 18309 +20
Misses 2149 2149 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
We've added Spree::SoftDeletable to maybe too many models. Especially Spree::Price does not need soft-deletion, as variants already have it. This adds a module that can be included instead of Spree::SoftDeletable, that defines the methods that the Discard gem defines, and deprecates all of these methods.
072edbc to
609f65e
Compare
b958563 to
1086995
Compare
We don't need soft delete on a model that belongs to an already soft-deleted model. It'll disappear anyway.
1086995 to
ab48ab6
Compare
tvdeyen
reviewed
Jan 5, 2026
Member
tvdeyen
left a comment
There was a problem hiding this comment.
I very much like this change, but we should think about the deprecation strategy
| module Spree | ||
| # Implements all of the methods that Discard implements, but without a deleted_at column. | ||
| # Deprecates all usages of Discard methods. | ||
| module HardDeletable |
| class RemoveSoftDeletedPrices < ActiveRecord::Migration[7.0] | ||
| def up | ||
| discarded_prices = Spree::Price.where.not(deleted_at: nil) | ||
| affected_variant_ids = discarded_prices.map(&:variant_id).uniq |
Member
There was a problem hiding this comment.
This will be faster
discarded_prices.pluck("DISTINCT(variant_id)")| variant.prices.select do |price| | ||
| variant.discarded? || price.kept? | ||
| end.sort_by do |price| | ||
| variant.prices.sort_by do |price| |
Member
There was a problem hiding this comment.
Can we create a new price selector and make optional, deprecating the old one?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Prices belong to variants, and variants are already soft-deletable. Prices do not need to be soft-deletable, and soft-deletable prices just make everything hard to understand.
Note especially how none of the specs that had to be changed offer any explanation on what "soft-deleting" a price semantically means. It's all just "ok prices have a deleted at, so how would that behave if ...", and that behavior is always extremely close to prices without soft-deletion.
Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: