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 commitf265e0ddb1
, reversing changes made to08dfa9212d
. Reverted due to surprising behavior for applications. We need to deprecate this behavior first instead of raising by default.
This commit is contained in:
parent
e2cf0b1d78
commit
f3dfed7d06
3 changed files with 0 additions and 22 deletions
|
@ -34,22 +34,6 @@
|
||||||
|
|
||||||
*Dylan Thacker-Smith*
|
*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`.
|
* 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.
|
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.
|
||||||
|
|
|
@ -140,7 +140,6 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def serialize(value)
|
def serialize(value)
|
||||||
assert_valid_value(value)
|
|
||||||
mapping.fetch(value, value)
|
mapping.fetch(value, value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,6 @@ class EnumTest < ActiveRecord::TestCase
|
||||||
assert_not_equal @book, Book.where(status: [written]).first
|
assert_not_equal @book, Book.where(status: [written]).first
|
||||||
assert_not_equal @book, Book.where("status <> ?", published).first
|
assert_not_equal @book, Book.where("status <> ?", published).first
|
||||||
assert_equal @book, Book.where("status <> ?", written).first
|
assert_equal @book, Book.where("status <> ?", written).first
|
||||||
assert_empty Book.where(status: nil)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "find via where with symbols" do
|
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_not_equal @book, Book.where.not(status: :published).first
|
||||||
assert_equal @book, Book.where.not(status: :written).first
|
assert_equal @book, Book.where.not(status: :written).first
|
||||||
assert_equal books(:ddd), Book.where(read_status: :forgotten).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
|
end
|
||||||
|
|
||||||
test "find via where with strings" do
|
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_not_equal @book, Book.where.not(status: "published").first
|
||||||
assert_equal @book, Book.where.not(status: "written").first
|
assert_equal @book, Book.where.not(status: "written").first
|
||||||
assert_equal books(:ddd), Book.where(read_status: "forgotten").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
|
end
|
||||||
|
|
||||||
test "build from scope" do
|
test "build from scope" do
|
||||||
|
|
Loading…
Reference in a new issue