diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 8035aaef2f..b4426c78f4 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -34,22 +34,6 @@ *Dylan Thacker-Smith* -* Raise error when non-existent enum used in query. - - This change will raise an error when a non-existent enum is passed to a query. - Previously with MySQL this would return an unrelated record. Fixes #38687. - - ```ruby - class User < ActiveRecord::Base - enum status: { active: 0, non_active: 1 } - end - - User.where(status: :non_existing_status) - => ArgumentError ('non_existing_status' is not a valid status) - ``` - - *Atul Kanswal* - * Dump the schema or structure of a database when calling `db:migrate:name`. In previous versions of Rails, `rails db:migrate` would dump the schema of the database. In Rails 6, that holds true (`rails db:migrate` dumps all databases' schemas), but `rails db:migrate:name` does not share that behavior. diff --git a/activerecord/lib/active_record/enum.rb b/activerecord/lib/active_record/enum.rb index 6ab7fc2c4d..9e404dfedd 100644 --- a/activerecord/lib/active_record/enum.rb +++ b/activerecord/lib/active_record/enum.rb @@ -140,7 +140,6 @@ module ActiveRecord end def serialize(value) - assert_valid_value(value) mapping.fetch(value, value) end diff --git a/activerecord/test/cases/enum_test.rb b/activerecord/test/cases/enum_test.rb index be9d4ead7c..d5ef77330d 100644 --- a/activerecord/test/cases/enum_test.rb +++ b/activerecord/test/cases/enum_test.rb @@ -59,7 +59,6 @@ class EnumTest < ActiveRecord::TestCase assert_not_equal @book, Book.where(status: [written]).first assert_not_equal @book, Book.where("status <> ?", published).first assert_equal @book, Book.where("status <> ?", written).first - assert_empty Book.where(status: nil) end test "find via where with symbols" do @@ -70,8 +69,6 @@ class EnumTest < ActiveRecord::TestCase assert_not_equal @book, Book.where.not(status: :published).first assert_equal @book, Book.where.not(status: :written).first assert_equal books(:ddd), Book.where(read_status: :forgotten).first - exception = assert_raises(ArgumentError) { Book.where(status: :not_defined).first } - assert_match(/'not_defined' is not a valid status/, exception.message) end test "find via where with strings" do @@ -82,8 +79,6 @@ class EnumTest < ActiveRecord::TestCase assert_not_equal @book, Book.where.not(status: "published").first assert_equal @book, Book.where.not(status: "written").first assert_equal books(:ddd), Book.where(read_status: "forgotten").first - exception = assert_raises(ArgumentError) { Book.where(status: "not_defined").first } - assert_match(/'not_defined' is not a valid status/, exception.message) end test "build from scope" do