Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Fixes #10175 removes upper limit for property value

Damian Legawiec1b02b69fd5a5
diff --git a/core/app/models/spree/product_property.rb b/core/app/models/spree/product_property.rb
index 418d539d3e..10584ed4a1 100644
--- a/core/app/models/spree/product_property.rb
+++ b/core/app/models/spree/product_property.rb
@@ -9,8 +9,6 @@ module Spree
validates :property, presence: true
- validates :value, db_maximum_length: true
-
default_scope { order(:position) }
self.whitelisted_ransackable_attributes = ['value']
diff --git a/core/app/models/spree/validations/db_maximum_length_validator.rb b/core/app/models/spree/validations/db_maximum_length_validator.rb
deleted file mode 100644
index dad26df306..0000000000
--- a/core/app/models/spree/validations/db_maximum_length_validator.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-module Spree
- module Validations
- ##
- # Validates a field based on the maximum length of the underlying DB field, if there is one.
- class DbMaximumLengthValidator < ActiveModel::Validator
- def initialize(options)
- super
- @field = options[:field].to_s
- raise ArgumentError, 'a field must be specified to the validator' if @field.blank?
- end
-
- def validate(record)
- warn '`Spree::Validations::DbMaximumLengthValidator` is deprecated. Use `DbMaximumLengthValidator` instead.'
- limit = record.class.columns_hash[@field].limit
- value = record[@field.to_sym]
- if value && limit && value.to_s.length > limit
- record.errors.add(@field.to_sym, :too_long, count: limit)
- end
- end
- end
- end
-end
diff --git a/core/app/validators/db_maximum_length_validator.rb b/core/app/validators/db_maximum_length_validator.rb
index 33a4002412..67a2b3e535 100644
--- a/core/app/validators/db_maximum_length_validator.rb
+++ b/core/app/validators/db_maximum_length_validator.rb
@@ -2,6 +2,11 @@
# Validates a field based on the maximum length of the underlying DB field, if there is one.
class DbMaximumLengthValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
+ ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
+ `DbMaximumLengthValidator` is deprecated and will be removed in Spree 5.0.
+ Please remove any `db_maximum_length: true` validations from your codebase
+ DEPRECATION
+
limit = if defined?(Globalize)
record.class.translation_class.columns_hash[attribute.to_s].limit
else