mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-30 21:27:17 +00:00
Only set calculator if it's a new record (having an id)
Unless we have a ActiveRecord::NotNullViolation
```
ActiveRecord::NotNullViolation:
PG::NotNullViolation: ERROR: null value in column "calculable_id" of relation "spree_calculators" violates not-null constraint
DETAIL: Failing row contains (9370, Calculator::None, null, Spree::ShippingMethod, 2023-01-12 15:09:44.381142, 2023-01-12 15:09:44.381142).
# ------------------
# --- Caused by: ---
# PG::NotNullViolation:
# ERROR: null value in column "calculable_id" of relation "spree_calculators" violates not-null constraint
# DETAIL: Failing row contains (9370, Calculator::None, null, Spree::ShippingMethod, 2023-01-12 15:09:44.381142, 2023-01-12 15:09:44.381142).
```
This commit is contained in:
@@ -109,7 +109,7 @@ module Spree
|
||||
end
|
||||
|
||||
def init
|
||||
self.calculator ||= ::Calculator::None.new
|
||||
self.calculator ||= ::Calculator::None.new if new_record?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user