aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-01-04 12:26:01 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-01-04 12:26:01 -0300
commit6d72485b6977804a872dcfa5d7ade2cec74c768e (patch)
treeff4e2cf5ab8a010c00ee46ad8e7d26a479e416b5 /activerecord
parentc7a1fa364012c70e76d19b36881c9bde016091b8 (diff)
parentbf7b8c193ffe2d6a05272a6ed763d87cfe743bb4 (diff)
downloadrails-6d72485b6977804a872dcfa5d7ade2cec74c768e.tar.gz
rails-6d72485b6977804a872dcfa5d7ade2cec74c768e.tar.bz2
rails-6d72485b6977804a872dcfa5d7ade2cec74c768e.zip
Merge pull request #18325 from rafaelfranca/rm-remove-deprecations
Remove all deprecation code
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG.md64
-rw-r--r--activerecord/lib/active_record/associations/has_many_through_association.rb16
-rw-r--r--activerecord/lib/active_record/associations/preloader/association.rb4
-rw-r--r--activerecord/lib/active_record/attribute_methods.rb16
-rw-r--r--activerecord/lib/active_record/attribute_methods/read.rb11
-rw-r--r--activerecord/lib/active_record/attribute_methods/serialization.rb15
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb11
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb18
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb4
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/transaction.rb14
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_adapter.rb1
-rw-r--r--activerecord/lib/active_record/connection_adapters/column.rb7
-rw-r--r--activerecord/lib/active_record/connection_adapters/connection_specification.rb21
-rw-r--r--activerecord/lib/active_record/core.rb7
-rw-r--r--activerecord/lib/active_record/fixtures.rb6
-rw-r--r--activerecord/lib/active_record/inheritance.rb10
-rw-r--r--activerecord/lib/active_record/reflection.rb19
-rw-r--r--activerecord/lib/active_record/relation/predicate_builder/array_handler.rb2
-rw-r--r--activerecord/lib/active_record/sanitization.rb29
-rw-r--r--activerecord/lib/active_record/transactions.rb29
-rw-r--r--activerecord/lib/active_record/type/boolean.rb15
-rw-r--r--activerecord/lib/rails/generators/active_record/migration/templates/create_table_migration.rb2
-rw-r--r--activerecord/test/cases/ar_schema_test.rb71
-rw-r--r--activerecord/test/cases/associations/deprecated_counter_cache_on_has_many_through_test.rb26
-rw-r--r--activerecord/test/cases/attribute_methods_test.rb14
-rw-r--r--activerecord/test/cases/connection_adapters/connection_handler_test.rb4
-rw-r--r--activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb38
-rw-r--r--activerecord/test/cases/dirty_test.rb12
-rw-r--r--activerecord/test/cases/helper.rb3
-rw-r--r--activerecord/test/cases/migration/change_schema_test.rb17
-rw-r--r--activerecord/test/cases/migration/foreign_key_test.rb14
-rw-r--r--activerecord/test/cases/migration_test.rb10
-rw-r--r--activerecord/test/cases/reflection_test.rb22
-rw-r--r--activerecord/test/cases/relations_test.rb6
-rw-r--r--activerecord/test/cases/sanitize_test.rb11
-rw-r--r--activerecord/test/cases/serialized_attribute_test.rb6
-rw-r--r--activerecord/test/cases/transaction_callbacks_test.rb41
-rw-r--r--activerecord/test/cases/types_test.rb10
38 files changed, 174 insertions, 452 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 83224c522c..d1eee8e73e 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,3 +1,67 @@
+* Change the behavior of boolean columns to be closer to Ruby's semantics.
+
+ Before this change we had a small set of "truthy", and all others are "falsy".
+
+ Now, we have a small set of "falsy" values and all others are "truthy" matching
+ Ruby's semantics.
+
+ *Rafael Mendonça França*
+
+* Deprecate `ActiveRecord::Base.errors_in_transactional_callbacks=`.
+
+ *Rafael Mendonça França*
+
+* Change transaction callbacks to not swallowing errors.
+
+ Before this change any error raised inside a transaction callback are
+ rescued and printed in the logs.
+
+ Now these errors are not rescue anymore and just bubble up, as the other callbacks.
+
+ *Rafael Mendonça França*
+
+* Remove deprecated `sanitize_sql_hash_for_conditions`.
+
+ *Rafael Mendonça França*
+
+* Remove deprecated `Reflection#source_macro`.
+
+ *Rafael Mendonça França*
+
+* Remove deprecated `symbolized_base_class` and `symbolized_sti_name`.
+
+ *Rafael Mendonça França*
+
+* Remove deprecated `ActiveRecord::Base.disable_implicit_join_references=`.
+
+ *Rafael Mendonça França*
+
+* Remove deprecated access to connection specification using a string acessor.
+
+ Now all strings will be handled as a URL.
+
+ *Rafael Mendonça França*
+
+* Change the default `null` value for `timestamps` to `false`.
+
+ *Rafael Mendonça França*
+
+* Return an array of pools from `connection_pools`.
+
+ *Rafael Mendonça França*
+
+* Return a null column from `column_for_attribute` when no column exists.
+
+ *Rafael Mendonça França*
+
+* Remove deprecated `serialized_attributes`.
+
+ *Rafael Mendonça França*
+
+* Remove deprecated automatic counter caches on `has_many :through`.
+
+ *Rafael Mendonça França*
+
* Change the way in which callback chains can be halted.
The preferred method to halt a callback chain from now on is to explicitly
diff --git a/activerecord/lib/active_record/associations/has_many_through_association.rb b/activerecord/lib/active_record/associations/has_many_through_association.rb
index 7a050ca224..f1e784d771 100644
--- a/activerecord/lib/active_record/associations/has_many_through_association.rb
+++ b/activerecord/lib/active_record/associations/has_many_through_association.rb
@@ -1,5 +1,3 @@
-require 'active_support/core_ext/string/filters'
-
module ActiveRecord
# = Active Record Has Many Through Association
module Associations
@@ -49,16 +47,7 @@ module ActiveRecord
end
save_through_record(record)
- if has_cached_counter? && !through_reflection_updates_counter_cache?
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
- Automatic updating of counter caches on through associations has been
- deprecated, and will be removed in Rails 5. Instead, please set the
- appropriate `counter_cache` options on the `has_many` and `belongs_to`
- for your associations to #{through_reflection.name}.
- MSG
- update_counter_in_database(1)
- end
record
end
@@ -211,11 +200,6 @@ module ActiveRecord
def invertible_for?(record)
false
end
-
- def through_reflection_updates_counter_cache?
- counter_name = cached_counter_attribute_name
- inverse_updates_counter_named?(counter_name, through_reflection)
- end
end
end
end
diff --git a/activerecord/lib/active_record/associations/preloader/association.rb b/activerecord/lib/active_record/associations/preloader/association.rb
index a6e1a24360..afcaa5d55a 100644
--- a/activerecord/lib/active_record/associations/preloader/association.rb
+++ b/activerecord/lib/active_record/associations/preloader/association.rb
@@ -104,11 +104,11 @@ module ActiveRecord
end
def association_key_type
- @klass.type_for_attribute(association_key_name.to_s).type
+ @klass.column_for_attribute(association_key_name).type
end
def owner_key_type
- @model.type_for_attribute(owner_key_name.to_s).type
+ @model.column_for_attribute(owner_key_name).type
end
def load_slices(slices)
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb
index b7edac791e..8f165fb1dc 100644
--- a/activerecord/lib/active_record/attribute_methods.rb
+++ b/activerecord/lib/active_record/attribute_methods.rb
@@ -192,7 +192,8 @@ module ActiveRecord
end
# Returns the column object for the named attribute.
- # Returns nil if the named attribute does not exist.
+ # Returns a +ActiveRecord::ConnectionAdapters::NullColumn+ if the
+ # named attribute does not exist.
#
# class Person < ActiveRecord::Base
# end
@@ -202,17 +203,12 @@ module ActiveRecord
# # => #<ActiveRecord::ConnectionAdapters::Column:0x007ff4ab083980 @name="name", @sql_type="varchar(255)", @null=true, ...>
#
# person.column_for_attribute(:nothing)
- # # => nil
+ # # => #<ActiveRecord::ConnectionAdapters::NullColumn:0xXXX @name=nil, @sql_type=nil, @cast_type=#<Type::Value>, ...>
def column_for_attribute(name)
- column = columns_hash[name.to_s]
- if column.nil?
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
- `#column_for_attribute` will return a null object for non-existent
- columns in Rails 5. Use `#has_attribute?` if you need to check for
- an attribute's existence.
- MSG
+ name = name.to_s
+ columns_hash.fetch(name) do
+ ConnectionAdapters::NullColumn.new(name)
end
- column
end
end
diff --git a/activerecord/lib/active_record/attribute_methods/read.rb b/activerecord/lib/active_record/attribute_methods/read.rb
index 20f0936e52..f6ab543015 100644
--- a/activerecord/lib/active_record/attribute_methods/read.rb
+++ b/activerecord/lib/active_record/attribute_methods/read.rb
@@ -36,19 +36,8 @@ module ActiveRecord
extend ActiveSupport::Concern
module ClassMethods
- [:cache_attributes, :cached_attributes, :cache_attribute?].each do |method_name|
- define_method method_name do |*|
- cached_attributes_deprecation_warning(method_name)
- true
- end
- end
-
protected
- def cached_attributes_deprecation_warning(method_name)
- ActiveSupport::Deprecation.warn "Calling `#{method_name}` is no longer necessary. All attributes are cached."
- end
-
if Module.methods_transplantable?
def define_method_attribute(name)
method = ReaderMethodCache[name]
diff --git a/activerecord/lib/active_record/attribute_methods/serialization.rb b/activerecord/lib/active_record/attribute_methods/serialization.rb
index e5ec5ddca5..d0d8a968c5 100644
--- a/activerecord/lib/active_record/attribute_methods/serialization.rb
+++ b/activerecord/lib/active_record/attribute_methods/serialization.rb
@@ -1,5 +1,3 @@
-require 'active_support/core_ext/string/filters'
-
module ActiveRecord
module AttributeMethods
module Serialization
@@ -51,19 +49,6 @@ module ActiveRecord
Type::Serialized.new(type, coder)
end
end
-
- def serialized_attributes
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
- `serialized_attributes` is deprecated without replacement, and will
- be removed in Rails 5.0.
- MSG
-
- @serialized_attributes ||= Hash[
- columns.select { |t| t.cast_type.is_a?(Type::Serialized) }.map { |c|
- [c.name, c.cast_type.coder]
- }
- ]
- end
end
end
end
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
index 6235745fb2..1371317e3c 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -2,7 +2,6 @@ require 'thread'
require 'thread_safe'
require 'monitor'
require 'set'
-require 'active_support/core_ext/string/filters'
module ActiveRecord
# Raised when a connection could not be obtained within the connection
@@ -517,15 +516,7 @@ module ActiveRecord
def connection_pool_list
owner_to_pool.values.compact
end
-
- def connection_pools
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
- In the next release, this will return the same as `#connection_pool_list`.
- (An array of pools, rather than a hash mapping specs to pools.)
- MSG
-
- Hash[connection_pool_list.map { |pool| [pool.spec, pool] }]
- end
+ alias :connection_pools :connection_pool_list
def establish_connection(owner, spec)
@class_to_pool.clear
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
index 68d8a2cd6a..7eaa89c9a7 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -56,18 +56,6 @@ module ActiveRecord
end
end
- module TimestampDefaultDeprecation # :nodoc:
- def emit_warning_if_null_unspecified(options)
- return if options.key?(:null)
-
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
- `#timestamp` was called without specifying an option for `null`. In Rails 5,
- this behavior will change to `null: false`. You should manually specify
- `null: true` to prevent the behavior of your existing migrations from changing.
- MSG
- end
- end
-
class ReferenceDefinition # :nodoc:
def initialize(
name,
@@ -167,8 +155,6 @@ module ActiveRecord
# The table definitions
# The Columns are stored as a ColumnDefinition in the +columns+ attribute.
class TableDefinition
- include TimestampDefaultDeprecation
-
# An array of ColumnDefinition objects, representing the column changes
# that have been defined.
attr_accessor :indexes
@@ -375,7 +361,9 @@ module ActiveRecord
# t.timestamps null: false
def timestamps(*args)
options = args.extract_options!
- emit_warning_if_null_unspecified(options)
+
+ options[:null] = false if options[:null].nil?
+
column(:created_at, :datetime, options)
column(:updated_at, :datetime, options)
end
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
index 34d60493ea..0f44c332ae 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -851,14 +851,14 @@ module ActiveRecord
columns
end
- include TimestampDefaultDeprecation
# Adds timestamps (+created_at+ and +updated_at+) columns to +table_name+.
# Additional options (like <tt>null: false</tt>) are forwarded to #add_column.
#
# add_timestamps(:suppliers, null: false)
#
def add_timestamps(table_name, options = {})
- emit_warning_if_null_unspecified(options)
+ options[:null] = false if options[:null].nil?
+
add_column table_name, :created_at, :datetime, options
add_column table_name, :updated_at, :datetime, options
end
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb b/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb
index fd666c8c39..f6ef3b0675 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb
@@ -69,12 +69,7 @@ module ActiveRecord
def rollback_records
ite = records.uniq
while record = ite.shift
- begin
- record.rolledback! full_rollback?
- rescue => e
- raise if ActiveRecord::Base.raise_in_transactional_callbacks
- record.logger.error(e) if record.respond_to?(:logger) && record.logger
- end
+ record.rolledback! full_rollback?
end
ensure
ite.each do |i|
@@ -89,12 +84,7 @@ module ActiveRecord
def commit_records
ite = records.uniq
while record = ite.shift
- begin
- record.committed!
- rescue => e
- raise if ActiveRecord::Base.raise_in_transactional_callbacks
- record.logger.error(e) if record.respond_to?(:logger) && record.logger
- end
+ record.committed!
end
ensure
ite.each do |i|
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
index fa24d9b43f..c3a8bf5c74 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -25,7 +25,6 @@ module ActiveRecord
autoload :TableDefinition
autoload :Table
autoload :AlterTable
- autoload :TimestampDefaultDeprecation
end
autoload_at 'active_record/connection_adapters/abstract/connection_pool' do
diff --git a/activerecord/lib/active_record/connection_adapters/column.rb b/activerecord/lib/active_record/connection_adapters/column.rb
index 65d8b1a8ab..e74de60a83 100644
--- a/activerecord/lib/active_record/connection_adapters/column.rb
+++ b/activerecord/lib/active_record/connection_adapters/column.rb
@@ -5,7 +5,6 @@ module ActiveRecord
module ConnectionAdapters
# An abstract definition of a column in a table.
class Column
- TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE', 'on', 'ON'].to_set
FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE', 'off', 'OFF'].to_set
module Format
@@ -77,6 +76,12 @@ module ActiveRecord
[self.class, name, default, cast_type, sql_type, null, default_function]
end
end
+
+ class NullColumn < Column
+ def initialize(name)
+ super name, nil, Type::Value.new
+ end
+ end
end
# :startdoc:
end
diff --git a/activerecord/lib/active_record/connection_adapters/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/connection_specification.rb
index e54e3199ff..08d46fca96 100644
--- a/activerecord/lib/active_record/connection_adapters/connection_specification.rb
+++ b/activerecord/lib/active_record/connection_adapters/connection_specification.rb
@@ -1,5 +1,4 @@
require 'uri'
-require 'active_support/core_ext/string/filters'
module ActiveRecord
module ConnectionAdapters
@@ -210,30 +209,12 @@ module ActiveRecord
when Symbol
resolve_symbol_connection spec
when String
- resolve_string_connection spec
+ resolve_url_connection spec
when Hash
resolve_hash_connection spec
end
end
- def resolve_string_connection(spec)
- # Rails has historically accepted a string to mean either
- # an environment key or a URL spec, so we have deprecated
- # this ambiguous behaviour and in the future this function
- # can be removed in favor of resolve_url_connection.
- if configurations.key?(spec) || spec !~ /:/
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
- Passing a string to ActiveRecord::Base.establish_connection for a
- configuration lookup is deprecated, please pass a symbol
- (#{spec.to_sym.inspect}) instead.
- MSG
-
- resolve_symbol_connection(spec)
- else
- resolve_url_connection(spec)
- end
- end
-
# Takes the environment such as +:production+ or +:development+.
# This requires that the @configurations was initialized with a key that
# matches.
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb
index 38b2d632d2..5c7c0feeb7 100644
--- a/activerecord/lib/active_record/core.rb
+++ b/activerecord/lib/active_record/core.rb
@@ -87,13 +87,6 @@ module ActiveRecord
mattr_accessor :maintain_test_schema, instance_accessor: false
- def self.disable_implicit_join_references=(value)
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
- Implicit join references were removed with Rails 4.1.
- Make sure to remove this configuration because it does nothing.
- MSG
- end
-
class_attribute :default_connection_handler, instance_writer: false
class_attribute :find_by_statement_cache
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb
index 4732462b05..3c71936c3b 100644
--- a/activerecord/lib/active_record/fixtures.rb
+++ b/activerecord/lib/active_record/fixtures.rb
@@ -768,12 +768,6 @@ module ActiveRecord
end
- #--
- # Deprecate 'Fixtures' in favor of 'FixtureSet'.
- #++
- # :nodoc:
- Fixtures = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('ActiveRecord::Fixtures', 'ActiveRecord::FixtureSet')
-
class Fixture #:nodoc:
include Enumerable
diff --git a/activerecord/lib/active_record/inheritance.rb b/activerecord/lib/active_record/inheritance.rb
index b91e9ac137..fd1e22349b 100644
--- a/activerecord/lib/active_record/inheritance.rb
+++ b/activerecord/lib/active_record/inheritance.rb
@@ -79,16 +79,6 @@ module ActiveRecord
:true == (@finder_needs_type_condition ||= descends_from_active_record? ? :false : :true)
end
- def symbolized_base_class
- ActiveSupport::Deprecation.warn('`ActiveRecord::Base.symbolized_base_class` is deprecated and will be removed without replacement.')
- @symbolized_base_class ||= base_class.to_s.to_sym
- end
-
- def symbolized_sti_name
- ActiveSupport::Deprecation.warn('`ActiveRecord::Base.symbolized_sti_name` is deprecated and will be removed without replacement.')
- @symbolized_sti_name ||= sti_name.present? ? sti_name.to_sym : symbolized_base_class
- end
-
# Returns the class descending directly from ActiveRecord::Base, or
# an abstract class, if any, in the inheritance hierarchy.
#
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index 7696ef13c7..66f2b6b768 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -153,15 +153,6 @@ module ActiveRecord
JoinKeys.new(foreign_key, active_record_primary_key)
end
- def source_macro
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
- ActiveRecord::Base.source_macro is deprecated and will be removed
- without replacement.
- MSG
-
- macro
- end
-
def constraints
scope_chain.flatten
end
@@ -763,16 +754,6 @@ module ActiveRecord
source_reflection.join_keys(association_klass)
end
- # The macro used by the source association
- def source_macro
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
- ActiveRecord::Base.source_macro is deprecated and will be removed
- without replacement.
- MSG
-
- source_reflection.source_macro
- end
-
# A through association is nested if there would be more than one join table
def nested?
chain.length > 2
diff --git a/activerecord/lib/active_record/relation/predicate_builder/array_handler.rb b/activerecord/lib/active_record/relation/predicate_builder/array_handler.rb
index 4b5f5773a0..95dbd6a77f 100644
--- a/activerecord/lib/active_record/relation/predicate_builder/array_handler.rb
+++ b/activerecord/lib/active_record/relation/predicate_builder/array_handler.rb
@@ -1,5 +1,3 @@
-require 'active_support/core_ext/string/filters'
-
module ActiveRecord
class PredicateBuilder
class ArrayHandler # :nodoc:
diff --git a/activerecord/lib/active_record/sanitization.rb b/activerecord/lib/active_record/sanitization.rb
index f5aa60a69a..768a72a947 100644
--- a/activerecord/lib/active_record/sanitization.rb
+++ b/activerecord/lib/active_record/sanitization.rb
@@ -72,35 +72,6 @@ module ActiveRecord
expanded_attrs
end
- # Sanitizes a hash of attribute/value pairs into SQL conditions for a WHERE clause.
- # { name: "foo'bar", group_id: 4 }
- # # => "name='foo''bar' and group_id= 4"
- # { status: nil, group_id: [1,2,3] }
- # # => "status IS NULL and group_id IN (1,2,3)"
- # { age: 13..18 }
- # # => "age BETWEEN 13 AND 18"
- # { 'other_records.id' => 7 }
- # # => "`other_records`.`id` = 7"
- # { other_records: { id: 7 } }
- # # => "`other_records`.`id` = 7"
- # And for value objects on a composed_of relationship:
- # { address: Address.new("123 abc st.", "chicago") }
- # # => "address_street='123 abc st.' and address_city='chicago'"
- def sanitize_sql_hash_for_conditions(attrs, default_table_name = self.table_name)
- table = Arel::Table.new(table_name).alias(default_table_name)
- predicate_builder = PredicateBuilder.new(TableMetadata.new(self, table))
- ActiveSupport::Deprecation.warn(<<-EOWARN)
-sanitize_sql_hash_for_conditions is deprecated, and will be removed in Rails 5.0
- EOWARN
- attrs = predicate_builder.resolve_column_aliases(attrs)
- attrs = expand_hash_conditions_for_aggregates(attrs)
-
- predicate_builder.build_from_hash(attrs).map { |b|
- connection.visitor.compile b
- }.join(' AND ')
- end
- alias_method :sanitize_sql_hash, :sanitize_sql_hash_for_conditions
-
# Sanitizes a hash of attribute/value pairs into SQL conditions for a SET clause.
# { status: nil, group_id: 1 }
# # => "status = NULL , group_id = 1"
diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb
index 31ca90fb58..1c48196762 100644
--- a/activerecord/lib/active_record/transactions.rb
+++ b/activerecord/lib/active_record/transactions.rb
@@ -4,23 +4,10 @@ module ActiveRecord
extend ActiveSupport::Concern
#:nodoc:
ACTIONS = [:create, :destroy, :update]
- #:nodoc:
- CALLBACK_WARN_MESSAGE = "Currently, Active Record suppresses errors raised " \
- "within `after_rollback`/`after_commit` callbacks and only print them to " \
- "the logs. In the next version, these errors will no longer be suppressed. " \
- "Instead, the errors will propagate normally just like in other Active " \
- "Record callbacks.\n" \
- "\n" \
- "You can opt into the new behavior and remove this warning by setting:\n" \
- "\n" \
- " config.active_record.raise_in_transactional_callbacks = true\n\n"
included do
define_callbacks :commit, :rollback,
scope: [:kind, :name]
-
- mattr_accessor :raise_in_transactional_callbacks, instance_writer: false
- self.raise_in_transactional_callbacks = false
end
# = Active Record Transactions
@@ -236,9 +223,6 @@ module ActiveRecord
def after_commit(*args, &block)
set_options_for_callbacks!(args)
set_callback(:commit, :after, *args, &block)
- unless ActiveRecord::Base.raise_in_transactional_callbacks
- ActiveSupport::Deprecation.warn(CALLBACK_WARN_MESSAGE)
- end
end
# This callback is called after a create, update, or destroy are rolled back.
@@ -247,9 +231,16 @@ module ActiveRecord
def after_rollback(*args, &block)
set_options_for_callbacks!(args)
set_callback(:rollback, :after, *args, &block)
- unless ActiveRecord::Base.raise_in_transactional_callbacks
- ActiveSupport::Deprecation.warn(CALLBACK_WARN_MESSAGE)
- end
+ end
+
+ def raise_in_transactional_callbacks
+ ActiveSupport::Deprecation.warn('ActiveRecord::Base.raise_in_transactional_callbacks is deprecated and will be removed without replacement.')
+ true
+ end
+
+ def raise_in_transactional_callbacks=(value)
+ ActiveSupport::Deprecation.warn('ActiveRecord::Base.raise_in_transactional_callbacks= is deprecated, has no effect and will be removed without replacement.')
+ value
end
private
diff --git a/activerecord/lib/active_record/type/boolean.rb b/activerecord/lib/active_record/type/boolean.rb
index 978d16d524..2e24afc7c0 100644
--- a/activerecord/lib/active_record/type/boolean.rb
+++ b/activerecord/lib/active_record/type/boolean.rb
@@ -10,19 +10,10 @@ module ActiveRecord
def cast_value(value)
if value == ''
nil
- elsif ConnectionAdapters::Column::TRUE_VALUES.include?(value)
- true
- else
- if !ConnectionAdapters::Column::FALSE_VALUES.include?(value)
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
- You attempted to assign a value which is not explicitly `true` or `false`
- to a boolean column. Currently this value casts to `false`. This will
- change to match Ruby's semantics, and will cast to `true` in Rails 5.
- If you would like to maintain the current behavior, you should
- explicitly handle the values you would like cast to `false`.
- MSG
- end
+ elsif ConnectionAdapters::Column::FALSE_VALUES.include?(value)
false
+ else
+ true
end
end
end
diff --git a/activerecord/lib/rails/generators/active_record/migration/templates/create_table_migration.rb b/activerecord/lib/rails/generators/active_record/migration/templates/create_table_migration.rb
index f7bf6987c4..fd94a2d038 100644
--- a/activerecord/lib/rails/generators/active_record/migration/templates/create_table_migration.rb
+++ b/activerecord/lib/rails/generators/active_record/migration/templates/create_table_migration.rb
@@ -9,7 +9,7 @@ class <%= migration_class_name %> < ActiveRecord::Migration
<% end -%>
<% end -%>
<% if options[:timestamps] %>
- t.timestamps null: false
+ t.timestamps
<% end -%>
end
<% attributes_with_index.each do |attribute| -%>
diff --git a/activerecord/test/cases/ar_schema_test.rb b/activerecord/test/cases/ar_schema_test.rb
index 025c9fe6f9..f4e8003bc3 100644
--- a/activerecord/test/cases/ar_schema_test.rb
+++ b/activerecord/test/cases/ar_schema_test.rb
@@ -93,69 +93,38 @@ if ActiveRecord::Base.connection.supports_migrations?
assert_equal "20131219224947", ActiveRecord::SchemaMigration.normalize_migration_number("20131219224947")
end
- def test_timestamps_without_null_is_deprecated_on_create_table
- assert_deprecated do
- ActiveRecord::Schema.define do
- create_table :has_timestamps do |t|
- t.timestamps
- end
+ def test_timestamps_without_null_set_null_to_false_on_create_table
+ ActiveRecord::Schema.define do
+ create_table :has_timestamps do |t|
+ t.timestamps
end
end
+
+ assert !@connection.columns(:has_timestamps).find { |c| c.name == 'created_at' }.null
+ assert !@connection.columns(:has_timestamps).find { |c| c.name == 'updated_at' }.null
end
- def test_timestamps_without_null_is_deprecated_on_change_table
- assert_deprecated do
- ActiveRecord::Schema.define do
- create_table :has_timestamps
+ def test_timestamps_without_null_set_null_to_false_on_change_table
+ ActiveRecord::Schema.define do
+ create_table :has_timestamps
- change_table :has_timestamps do |t|
- t.timestamps
- end
+ change_table :has_timestamps do |t|
+ t.timestamps default: Time.now
end
end
- end
- def test_timestamps_without_null_is_deprecated_on_add_timestamps
- assert_deprecated do
- ActiveRecord::Schema.define do
- create_table :has_timestamps
- add_timestamps :has_timestamps
- end
- end
+ assert !@connection.columns(:has_timestamps).find { |c| c.name == 'created_at' }.null
+ assert !@connection.columns(:has_timestamps).find { |c| c.name == 'updated_at' }.null
end
- def test_no_deprecation_warning_from_timestamps_on_create_table
- assert_not_deprecated do
- ActiveRecord::Schema.define do
- create_table :has_timestamps do |t|
- t.timestamps null: true
- end
-
- drop_table :has_timestamps
-
- create_table :has_timestamps do |t|
- t.timestamps null: false
- end
- end
+ def test_timestamps_without_null_set_null_to_false_on_add_timestamps
+ ActiveRecord::Schema.define do
+ create_table :has_timestamps
+ add_timestamps :has_timestamps, default: Time.now
end
- end
-
- def test_no_deprecation_warning_from_timestamps_on_change_table
- assert_not_deprecated do
- ActiveRecord::Schema.define do
- create_table :has_timestamps
- change_table :has_timestamps do |t|
- t.timestamps null: true
- end
- drop_table :has_timestamps
-
- create_table :has_timestamps
- change_table :has_timestamps do |t|
- t.timestamps null: false, default: Time.now
- end
- end
- end
+ assert !@connection.columns(:has_timestamps).find { |c| c.name == 'created_at' }.null
+ assert !@connection.columns(:has_timestamps).find { |c| c.name == 'updated_at' }.null
end
end
end
diff --git a/activerecord/test/cases/associations/deprecated_counter_cache_on_has_many_through_test.rb b/activerecord/test/cases/associations/deprecated_counter_cache_on_has_many_through_test.rb
deleted file mode 100644
index 48f7ddbe83..0000000000
--- a/activerecord/test/cases/associations/deprecated_counter_cache_on_has_many_through_test.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require "cases/helper"
-
-class DeprecatedCounterCacheOnHasManyThroughTest < ActiveRecord::TestCase
- class Post < ActiveRecord::Base
- has_many :taggings, as: :taggable
- has_many :tags, through: :taggings
- end
-
- class Tagging < ActiveRecord::Base
- belongs_to :taggable, polymorphic: true
- belongs_to :tag
- end
-
- class Tag < ActiveRecord::Base
- end
-
- test "counter caches are updated in the database if the belongs_to association doesn't specify a counter cache" do
- post = Post.create!(title: 'Hello', body: 'World!')
- assert_deprecated { post.tags << Tag.create!(name: 'whatever') }
-
- assert_equal 1, post.tags.size
- assert_equal 1, post.tags_count
- assert_equal 1, post.reload.tags.size
- assert_equal 1, post.reload.tags_count
- end
-end
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb
index 731d433706..feb1fca500 100644
--- a/activerecord/test/cases/attribute_methods_test.rb
+++ b/activerecord/test/cases/attribute_methods_test.rb
@@ -531,20 +531,6 @@ class AttributeMethodsTest < ActiveRecord::TestCase
end
end
- def test_deprecated_cache_attributes
- assert_deprecated do
- Topic.cache_attributes :replies_count
- end
-
- assert_deprecated do
- Topic.cached_attributes
- end
-
- assert_deprecated do
- Topic.cache_attribute? :replies_count
- end
- end
-
def test_converted_values_are_returned_after_assignment
developer = Developer.new(name: 1337, salary: "50000")
diff --git a/activerecord/test/cases/connection_adapters/connection_handler_test.rb b/activerecord/test/cases/connection_adapters/connection_handler_test.rb
index 3e33b30144..b72f8ca88c 100644
--- a/activerecord/test/cases/connection_adapters/connection_handler_test.rb
+++ b/activerecord/test/cases/connection_adapters/connection_handler_test.rb
@@ -44,9 +44,7 @@ module ActiveRecord
end
def test_connection_pools
- assert_deprecated do
- assert_equal({ Base.connection_pool.spec => @pool }, @handler.connection_pools)
- end
+ assert_equal([@pool], @handler.connection_pools)
end
end
end
diff --git a/activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb b/activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb
index 37ad469476..9ee92a3cd2 100644
--- a/activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb
+++ b/activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb
@@ -51,34 +51,6 @@ module ActiveRecord
assert_equal expected, actual
end
- def test_resolver_with_database_uri_and_and_current_env_string_key
- ENV['DATABASE_URL'] = "postgres://localhost/foo"
- config = { "default_env" => { "adapter" => "not_postgres", "database" => "not_foo" } }
- actual = assert_deprecated { resolve_spec("default_env", config) }
- expected = { "adapter"=>"postgresql", "database"=>"foo", "host"=>"localhost" }
- assert_equal expected, actual
- end
-
- def test_resolver_with_database_uri_and_and_current_env_string_key_and_rails_env
- ENV['DATABASE_URL'] = "postgres://localhost/foo"
- ENV['RAILS_ENV'] = "foo"
-
- config = { "not_production" => {"adapter" => "not_postgres", "database" => "not_foo" } }
- actual = assert_deprecated { resolve_spec("foo", config) }
- expected = { "adapter" => "postgresql", "database" => "foo", "host" => "localhost" }
- assert_equal expected, actual
- end
-
- def test_resolver_with_database_uri_and_and_current_env_string_key_and_rack_env
- ENV['DATABASE_URL'] = "postgres://localhost/foo"
- ENV['RACK_ENV'] = "foo"
-
- config = { "not_production" => {"adapter" => "not_postgres", "database" => "not_foo" } }
- actual = assert_deprecated { resolve_spec("foo", config) }
- expected = { "adapter" => "postgresql", "database" => "foo", "host" => "localhost" }
- assert_equal expected, actual
- end
-
def test_resolver_with_database_uri_and_known_key
ENV['DATABASE_URL'] = "postgres://localhost/foo"
config = { "production" => { "adapter" => "not_postgres", "database" => "not_foo", "host" => "localhost" } }
@@ -95,16 +67,6 @@ module ActiveRecord
end
end
- def test_resolver_with_database_uri_and_unknown_string_key
- ENV['DATABASE_URL'] = "postgres://localhost/foo"
- config = { "not_production" => { "adapter" => "not_postgres", "database" => "not_foo" } }
- assert_deprecated do
- assert_raises AdapterNotSpecified do
- resolve_spec("production", config)
- end
- end
- end
-
def test_resolver_with_database_uri_and_supplied_url
ENV['DATABASE_URL'] = "not-postgres://not-localhost/not_foo"
config = { "production" => { "adapter" => "also_not_postgres", "database" => "also_not_foo" } }
diff --git a/activerecord/test/cases/dirty_test.rb b/activerecord/test/cases/dirty_test.rb
index 98cf60a8c4..5b71bd7e67 100644
--- a/activerecord/test/cases/dirty_test.rb
+++ b/activerecord/test/cases/dirty_test.rb
@@ -165,18 +165,6 @@ class DirtyTest < ActiveRecord::TestCase
assert_equal parrot.name_change, parrot.title_change
end
- def test_reset_attribute!
- pirate = Pirate.create!(:catchphrase => 'Yar!')
- pirate.catchphrase = 'Ahoy!'
-
- assert_deprecated do
- pirate.reset_catchphrase!
- end
- assert_equal "Yar!", pirate.catchphrase
- assert_equal Hash.new, pirate.changes
- assert !pirate.catchphrase_changed?
- end
-
def test_restore_attribute!
pirate = Pirate.create!(:catchphrase => 'Yar!')
pirate.catchphrase = 'Ahoy!'
diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb
index 80ac57ec7c..925491acbd 100644
--- a/activerecord/test/cases/helper.rb
+++ b/activerecord/test/cases/helper.rb
@@ -24,9 +24,6 @@ ActiveSupport::Deprecation.debug = true
# Disable available locale checks to avoid warnings running the test suite.
I18n.enforce_available_locales = false
-# Enable raise errors in after_commit and after_rollback.
-ActiveRecord::Base.raise_in_transactional_callbacks = true
-
# Connect to the database
ARTest.connect
diff --git a/activerecord/test/cases/migration/change_schema_test.rb b/activerecord/test/cases/migration/change_schema_test.rb
index 337360e97f..b3129a8984 100644
--- a/activerecord/test/cases/migration/change_schema_test.rb
+++ b/activerecord/test/cases/migration/change_schema_test.rb
@@ -195,32 +195,29 @@ module ActiveRecord
end
def test_create_table_with_timestamps_should_create_datetime_columns
- # FIXME: Remove the silence when we change the default `null` behavior
- ActiveSupport::Deprecation.silence do
- connection.create_table table_name do |t|
- t.timestamps
- end
+ connection.create_table table_name do |t|
+ t.timestamps
end
created_columns = connection.columns(table_name)
created_at_column = created_columns.detect {|c| c.name == 'created_at' }
updated_at_column = created_columns.detect {|c| c.name == 'updated_at' }
- assert created_at_column.null
- assert updated_at_column.null
+ assert !created_at_column.null
+ assert !updated_at_column.null
end
def test_create_table_with_timestamps_should_create_datetime_columns_with_options
connection.create_table table_name do |t|
- t.timestamps :null => false
+ t.timestamps null: true
end
created_columns = connection.columns(table_name)
created_at_column = created_columns.detect {|c| c.name == 'created_at' }
updated_at_column = created_columns.detect {|c| c.name == 'updated_at' }
- assert !created_at_column.null
- assert !updated_at_column.null
+ assert created_at_column.null
+ assert updated_at_column.null
end
def test_create_table_without_a_block
diff --git a/activerecord/test/cases/migration/foreign_key_test.rb b/activerecord/test/cases/migration/foreign_key_test.rb
index 51e21528c2..ad35d690bd 100644
--- a/activerecord/test/cases/migration/foreign_key_test.rb
+++ b/activerecord/test/cases/migration/foreign_key_test.rb
@@ -29,7 +29,7 @@ module ActiveRecord
teardown do
if defined?(@connection)
- @connection.drop_table "astronauts" if @connection.table_exists? 'astronauts'
+ @connection.drop_table "astronauts" if @connection.table_exists? 'astronauts'
@connection.drop_table "rockets" if @connection.table_exists? 'rockets'
end
end
@@ -220,6 +220,18 @@ module ActiveRecord
ensure
silence_stream($stdout) { migration.migrate(:down) }
end
+
+ private
+
+ def silence_stream(stream)
+ old_stream = stream.dup
+ stream.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL:' : '/dev/null')
+ stream.sync = true
+ yield
+ ensure
+ stream.reopen(old_stream)
+ old_stream.close
+ end
end
end
end
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb
index 3192b797b4..5829ef2100 100644
--- a/activerecord/test/cases/migration_test.rb
+++ b/activerecord/test/cases/migration_test.rb
@@ -936,4 +936,14 @@ class CopyMigrationsTest < ActiveRecord::TestCase
end
end
end
+
+ def silence_stream(stream)
+ old_stream = stream.dup
+ stream.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL:' : '/dev/null')
+ stream.sync = true
+ yield
+ ensure
+ stream.reopen(old_stream)
+ old_stream.close
+ end
end
diff --git a/activerecord/test/cases/reflection_test.rb b/activerecord/test/cases/reflection_test.rb
index e86b892a0a..a2252a836f 100644
--- a/activerecord/test/cases/reflection_test.rb
+++ b/activerecord/test/cases/reflection_test.rb
@@ -80,10 +80,24 @@ class ReflectionTest < ActiveRecord::TestCase
assert_equal :integer, @first.column_for_attribute("id").type
end
- def test_non_existent_columns_return_nil
- assert_deprecated do
- assert_nil @first.column_for_attribute("attribute_that_doesnt_exist")
- end
+ def test_non_existent_columns_return_null_object
+ column = @first.column_for_attribute("attribute_that_doesnt_exist")
+ assert_instance_of ActiveRecord::ConnectionAdapters::NullColumn, column
+ assert_equal "attribute_that_doesnt_exist", column.name
+ assert_equal nil, column.sql_type
+ assert_equal nil, column.type
+ assert_not column.number?
+ assert_not column.text?
+ assert_not column.binary?
+ end
+
+ def test_non_existent_columns_are_identity_types
+ column = @first.column_for_attribute("attribute_that_doesnt_exist")
+ object = Object.new
+
+ assert_equal object, column.type_cast_from_database(object)
+ assert_equal object, column.type_cast_from_user(object)
+ assert_equal object, column.type_cast_for_database(object)
end
def test_reflection_klass_for_nested_class_name
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index fb9258c038..2e2c5ee10b 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -1382,12 +1382,6 @@ class RelationTest < ActiveRecord::TestCase
assert_equal "id", Post.all.primary_key
end
- def test_disable_implicit_join_references_is_deprecated
- assert_deprecated do
- ActiveRecord::Base.disable_implicit_join_references = true
- end
- end
-
def test_ordering_with_extra_spaces
assert_equal authors(:david), Author.order('id DESC , name DESC').last
end
diff --git a/activerecord/test/cases/sanitize_test.rb b/activerecord/test/cases/sanitize_test.rb
index f477cf7d92..262e0abc22 100644
--- a/activerecord/test/cases/sanitize_test.rb
+++ b/activerecord/test/cases/sanitize_test.rb
@@ -7,17 +7,6 @@ class SanitizeTest < ActiveRecord::TestCase
def setup
end
- def test_sanitize_sql_hash_handles_associations
- quoted_bambi = ActiveRecord::Base.connection.quote("Bambi")
- quoted_column_name = ActiveRecord::Base.connection.quote_column_name("name")
- quoted_table_name = ActiveRecord::Base.connection.quote_table_name("adorable_animals")
- expected_value = "#{quoted_table_name}.#{quoted_column_name} = #{quoted_bambi}"
-
- assert_deprecated do
- assert_equal expected_value, Binary.send(:sanitize_sql_hash, {adorable_animals: {name: 'Bambi'}})
- end
- end
-
def test_sanitize_sql_array_handles_string_interpolation
quoted_bambi = ActiveRecord::Base.connection.quote_string("Bambi")
assert_equal "name=#{quoted_bambi}", Binary.send(:sanitize_sql_array, ["name=%s", "Bambi"])
diff --git a/activerecord/test/cases/serialized_attribute_test.rb b/activerecord/test/cases/serialized_attribute_test.rb
index c261a5b1c0..e29f7462c8 100644
--- a/activerecord/test/cases/serialized_attribute_test.rb
+++ b/activerecord/test/cases/serialized_attribute_test.rb
@@ -22,12 +22,6 @@ class SerializedAttributeTest < ActiveRecord::TestCase
end
end
- def test_list_of_serialized_attributes
- assert_deprecated do
- assert_equal %w(content), Topic.serialized_attributes.keys
- end
- end
-
def test_serialized_attribute
Topic.serialize("content", MyObject)
diff --git a/activerecord/test/cases/transaction_callbacks_test.rb b/activerecord/test/cases/transaction_callbacks_test.rb
index 0f5caa52e3..185fc22e98 100644
--- a/activerecord/test/cases/transaction_callbacks_test.rb
+++ b/activerecord/test/cases/transaction_callbacks_test.rb
@@ -266,47 +266,6 @@ class TransactionCallbacksTest < ActiveRecord::TestCase
assert_equal 2, @first.rollbacks
end
- def test_after_transaction_callbacks_should_prevent_callbacks_from_being_called
- old_transaction_config = ActiveRecord::Base.raise_in_transactional_callbacks
- ActiveRecord::Base.raise_in_transactional_callbacks = false
-
- def @first.last_after_transaction_error=(e); @last_transaction_error = e; end
- def @first.last_after_transaction_error; @last_transaction_error; end
- @first.after_commit_block{|r| r.last_after_transaction_error = :commit; raise "fail!";}
- @first.after_rollback_block{|r| r.last_after_transaction_error = :rollback; raise "fail!";}
-
- second = TopicWithCallbacks.find(3)
- second.after_commit_block{|r| r.history << :after_commit}
- second.after_rollback_block{|r| r.history << :after_rollback}
-
- Topic.transaction do
- @first.save!
- second.save!
- end
- assert_equal :commit, @first.last_after_transaction_error
- assert_equal [:after_commit], second.history
-
- second.history.clear
- Topic.transaction do
- @first.save!
- second.save!
- raise ActiveRecord::Rollback
- end
- assert_equal :rollback, @first.last_after_transaction_error
- assert_equal [:after_rollback], second.history
- ensure
- ActiveRecord::Base.raise_in_transactional_callbacks = old_transaction_config
- end
-
- def test_after_commit_should_not_raise_when_raise_in_transactional_callbacks_false
- old_transaction_config = ActiveRecord::Base.raise_in_transactional_callbacks
- ActiveRecord::Base.raise_in_transactional_callbacks = false
- @first.after_commit_block{ fail "boom" }
- Topic.transaction { @first.save! }
- ensure
- ActiveRecord::Base.raise_in_transactional_callbacks = old_transaction_config
- end
-
def test_after_commit_callback_should_not_swallow_errors
@first.after_commit_block{ fail "boom" }
assert_raises(RuntimeError) do
diff --git a/activerecord/test/cases/types_test.rb b/activerecord/test/cases/types_test.rb
index b0979cbe1f..73e92addfe 100644
--- a/activerecord/test/cases/types_test.rb
+++ b/activerecord/test/cases/types_test.rb
@@ -17,6 +17,10 @@ module ActiveRecord
assert type.type_cast_from_user('TRUE')
assert type.type_cast_from_user('on')
assert type.type_cast_from_user('ON')
+ assert type.type_cast_from_user(' ')
+ assert type.type_cast_from_user("\u3000\r\n")
+ assert type.type_cast_from_user("\u0000")
+ assert type.type_cast_from_user('SOMETHING RANDOM')
# explicitly check for false vs nil
assert_equal false, type.type_cast_from_user(false)
@@ -28,12 +32,6 @@ module ActiveRecord
assert_equal false, type.type_cast_from_user('FALSE')
assert_equal false, type.type_cast_from_user('off')
assert_equal false, type.type_cast_from_user('OFF')
- assert_deprecated do
- assert_equal false, type.type_cast_from_user(' ')
- assert_equal false, type.type_cast_from_user("\u3000\r\n")
- assert_equal false, type.type_cast_from_user("\u0000")
- assert_equal false, type.type_cast_from_user('SOMETHING RANDOM')
- end
end
def test_type_cast_float