Moved database-specific ActiveModel types into ActiveRecord
ie. DecimalWithoutScale, Text and UnsignedInteger
This commit is contained in:
parent
159b774887
commit
994ce87bbd
@ -1,3 +1,7 @@
|
||||
* Moved DecimalWithoutScale, Text, and UnsignedInteger from Active Model to Active Record
|
||||
|
||||
*Iain Beeston*
|
||||
|
||||
* Removed deprecated `:tokenizer` in the length validator.
|
||||
|
||||
*Rafael Mendonça França*
|
||||
|
@ -7,14 +7,11 @@
|
||||
require "active_model/type/date"
|
||||
require "active_model/type/date_time"
|
||||
require "active_model/type/decimal"
|
||||
require "active_model/type/decimal_without_scale"
|
||||
require "active_model/type/float"
|
||||
require "active_model/type/immutable_string"
|
||||
require "active_model/type/integer"
|
||||
require "active_model/type/string"
|
||||
require "active_model/type/text"
|
||||
require "active_model/type/time"
|
||||
require "active_model/type/unsigned_integer"
|
||||
|
||||
require "active_model/type/registry"
|
||||
|
||||
@ -53,7 +50,6 @@ def lookup(*args, **kwargs) # :nodoc:
|
||||
register(:immutable_string, Type::ImmutableString)
|
||||
register(:integer, Type::Integer)
|
||||
register(:string, Type::String)
|
||||
register(:text, Type::Text)
|
||||
register(:time, Type::Time)
|
||||
end
|
||||
end
|
||||
|
@ -1,11 +0,0 @@
|
||||
require "active_model/type/big_integer"
|
||||
|
||||
module ActiveModel
|
||||
module Type
|
||||
class DecimalWithoutScale < BigInteger # :nodoc:
|
||||
def type
|
||||
:decimal
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,11 +0,0 @@
|
||||
require "active_model/type/string"
|
||||
|
||||
module ActiveModel
|
||||
module Type
|
||||
class Text < String # :nodoc:
|
||||
def type
|
||||
:text
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,3 +1,7 @@
|
||||
* Moved DecimalWithoutScale, Text, and UnsignedInteger from Active Model to Active Record
|
||||
|
||||
*Iain Beeston*
|
||||
|
||||
* Fixed support for case insensitive comparisons of `text` columns in
|
||||
PostgreSQL.
|
||||
|
||||
|
@ -7,7 +7,10 @@
|
||||
|
||||
require "active_record/type/date"
|
||||
require "active_record/type/date_time"
|
||||
require "active_record/type/decimal_without_scale"
|
||||
require "active_record/type/time"
|
||||
require "active_record/type/text"
|
||||
require "active_record/type/unsigned_integer"
|
||||
|
||||
require "active_record/type/serialized"
|
||||
require "active_record/type/adapter_specific_registry"
|
||||
@ -54,12 +57,9 @@ def current_adapter_name
|
||||
Binary = ActiveModel::Type::Binary
|
||||
Boolean = ActiveModel::Type::Boolean
|
||||
Decimal = ActiveModel::Type::Decimal
|
||||
DecimalWithoutScale = ActiveModel::Type::DecimalWithoutScale
|
||||
Float = ActiveModel::Type::Float
|
||||
Integer = ActiveModel::Type::Integer
|
||||
String = ActiveModel::Type::String
|
||||
Text = ActiveModel::Type::Text
|
||||
UnsignedInteger = ActiveModel::Type::UnsignedInteger
|
||||
|
||||
register(:big_integer, Type::BigInteger, override: false)
|
||||
register(:binary, Type::Binary, override: false)
|
||||
|
@ -0,0 +1,9 @@
|
||||
module ActiveRecord
|
||||
module Type
|
||||
class DecimalWithoutScale < ActiveModel::Type::BigInteger # :nodoc:
|
||||
def type
|
||||
:decimal
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
9
activerecord/lib/active_record/type/text.rb
Normal file
9
activerecord/lib/active_record/type/text.rb
Normal file
@ -0,0 +1,9 @@
|
||||
module ActiveRecord
|
||||
module Type
|
||||
class Text < ActiveModel::Type::String # :nodoc:
|
||||
def type
|
||||
:text
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,6 +1,6 @@
|
||||
module ActiveModel
|
||||
module ActiveRecord
|
||||
module Type
|
||||
class UnsignedInteger < Integer # :nodoc:
|
||||
class UnsignedInteger < ActiveModel::Type::Integer # :nodoc:
|
||||
private
|
||||
|
||||
def max_value
|
@ -1,9 +1,8 @@
|
||||
require "cases/helper"
|
||||
require "active_model/type"
|
||||
|
||||
module ActiveModel
|
||||
module ActiveRecord
|
||||
module Type
|
||||
class UnsignedIntegerTest < ActiveModel::TestCase
|
||||
class UnsignedIntegerTest < ActiveRecord::TestCase
|
||||
test "unsigned int max value is in range" do
|
||||
assert_equal(4294967295, UnsignedInteger.new.serialize(4294967295))
|
||||
end
|
Loading…
Reference in New Issue
Block a user