1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Revert "Merge pull request #38737 from ak15/active_record_enum"

This reverts commit f265e0ddb1, reversing
changes made to 08dfa9212d.

Reverted due to surprising behavior for applications. We need to
deprecate this behavior first instead of raising by default.
This commit is contained in:
eileencodes 2020-03-26 13:49:38 -04:00
parent e2cf0b1d78
commit f3dfed7d06
No known key found for this signature in database
GPG key ID: BA5C575120BBE8DF
3 changed files with 0 additions and 22 deletions

View file

@ -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.

View file

@ -140,7 +140,6 @@ module ActiveRecord
end
def serialize(value)
assert_valid_value(value)
mapping.fetch(value, value)
end

View file

@ -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