- 10 7月, 2020 1 次提交
-
-
由 Ryuta Kamizono 提交于
```ruby class Book < ActiveRecord::Base enum status: [:proposed, :written, :published], _default: :published end Book.new.status # => "published" ```
-
- 20 6月, 2020 3 次提交
-
-
由 Ryuta Kamizono 提交于
-
由 Ryuta Kamizono 提交于
This reverts commit 091164d2, reversing changes made to dde9e82c.
-
由 Sarah Vessels 提交于
-
- 13 5月, 2020 1 次提交
-
-
由 Ryuta Kamizono 提交于
That issues are caused by using only the model's cast types on the relation. To fix that issues, use the attribute's type caster takes precedence over the model's cast types on the relation. Fixes #35232. Fixes #36042. Fixes #37484.
-
- 08 4月, 2020 1 次提交
-
-
由 eileencodes 提交于
Testing that when you set a symbol for an enum type, you get a string back and that when you set a string you also get a string back.
-
- 27 3月, 2020 1 次提交
-
-
由 eileencodes 提交于
This reverts commit f265e0dd, reversing changes made to 08dfa921. Reverted due to surprising behavior for applications. We need to deprecate this behavior first instead of raising by default.
-
- 18 3月, 2020 1 次提交
-
-
由 ak 提交于
This behaviour is in rails/activerecord/lib/active_record/enum.rb #serialize(value) line no 143 if value is not present in mapping we are sending the value back , which in mysql returns unrelated record. I have changed to return nil is value is not present in mapping Implemented code review changes Improved test case coverage [ci skip] - cosmetic changes for better readibility of change log Signed-off-by: Nak <atulkanswal@gmail.com>
-
- 27 12月, 2019 1 次提交
-
-
由 Yoshiyuki Hirano 提交于
This commit will be squished into f4fbdb1b after maintainer's review.
-
- 25 12月, 2019 1 次提交
-
-
由 Yoshiyuki Hirano 提交于
If `AR::Enum` is used for boolean field, it would be not expected behavior for us. fixes #38075 Problem: In case of using boolean for enum, we can set with string (hash key) to instance, but we cannot set with actual value (hash value). ```ruby class Post < ActiveRecord::Base enum status: { enabled: true, disabled: false } end post.status = 'enabled' post.status # 'enabled' post.status = true post.status # 'enabled' post.status = 'disabled' post.status # 'disabled' post.status = false post.status # nil (This is not expected behavior) ``` After looking into `AR::Enum::EnumType#cast`, I found that `blank?` method converts from false value to nil (it seems it may not intentional behavior). In this patch, I improved that if it defines enum with boolean, it returns reasonable behavior.
-
- 30 7月, 2019 1 次提交
-
-
由 Ryuta Kamizono 提交于
To suppress the following warnings in tests. ``` ~/rails/activerecord/lib/active_record/scoping/named.rb:190: warning: method redefined; discarding old not_sent ~/rails/activerecord/lib/active_record/scoping/named.rb:190: warning: previous definition of not_sent was here ```
-
- 01 7月, 2019 1 次提交
-
-
由 Edu Depetris 提交于
When a enum element contains the prefix 'not_'. I warns to users to be aware of this new feature. Example code: class Foo < ActiveRecord::Base enum status: [:sent, :not_sent] end
-
- 27 2月, 2019 2 次提交
-
-
由 Ryuta Kamizono 提交于
[ci skip]
-
由 David Heinemeier Hansson 提交于
Add negative scopes for all enum values
-
- 04 12月, 2018 1 次提交
-
-
由 Alfred Dominic 提交于
-
- 24 11月, 2018 1 次提交
-
-
由 ebyrds 提交于
-
- 08 11月, 2018 1 次提交
-
-
由 Christophe Maximin 提交于
-
- 10 10月, 2018 1 次提交
-
-
由 Alberto Almagro 提交于
When defining a Hash enum it can be easy to use [] instead of {}. This commit checks that only valid definition values are provided, those can be a Hash, an array of Symbols or an array of Strings. Otherwise it raises an ArgumentError. Fixes #33961
-
- 26 1月, 2018 3 次提交
-
-
由 Daniel Colson 提交于
-
由 Daniel Colson 提交于
-
由 Daniel Colson 提交于
-
- 28 11月, 2017 1 次提交
-
-
由 Chen Kinnrot 提交于
Due to inconsistent behavior when chaining scopes and one scope named after a Relation method Validation code added in 2 places: - scope, to prevent problematic scope names. - enum, cause it tries to auto define scope.
-
- 23 8月, 2017 1 次提交
-
-
由 Yasuo Honda 提交于
`:authors` has a foreign key to `:author_addresses`. If only `:authors` fixture loaded into the database which supports foreign key and checks the existing data when enabling foreien keys like Oracle, it raises the following error `ORA-02298: cannot validate (ARUNIT.FK_RAILS_94423A17A3) - parent keys not found` It is because there is no parent data exists in `author_addresses` table. Here are how other database with foreign key support works: - MySQL does not check the existing data when enabling foreign key by `foreign_key_checks=1` https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_foreign_key_checks > Setting foreign_key_checks to 1 does not trigger a scan of the existing table data. Therefore, rows added to the table while foreign_key_checks=0 will not be verified for consistency. - PostgreSQL database itself has a feature to check existing data when enabling foreign key and discussed at #27636, which is reverted.
-
- 16 8月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
Since c51f9b61 changed the "_before_type_cast" expectation for enum.
-
- 20 7月, 2017 1 次提交
-
-
由 Kir Shatrov 提交于
-
- 02 7月, 2017 1 次提交
-
-
由 Matthew Draper 提交于
This reverts commit 3420a145, reversing changes made to afb66a5a.
-
- 01 7月, 2017 1 次提交
-
-
由 Kir Shatrov 提交于
-
- 31 5月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
If casted value is nil, generated SQL should be `IS NULL`. But currently it is generated as `= NULL`. To prevent this behavior, avoid making bind param if casted value is nil. Fixes #28945.
-
- 07 5月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
-
- 03 5月, 2017 1 次提交
-
- 12 9月, 2016 1 次提交
-
-
由 Yosuke Kabuto 提交于
Make name of attribute medium instead of normal
-
- 07 8月, 2016 1 次提交
-
-
由 Xavier Noria 提交于
The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
-
- 31 7月, 2016 1 次提交
-
-
由 Ryuta Kamizono 提交于
Fixes #25892.
-
- 24 6月, 2016 1 次提交
-
-
由 yuuji.yaginuma 提交于
-
- 23 1月, 2016 1 次提交
-
-
由 Sean Griffin 提交于
This fixes incorrect assumptions made by e991c7b8 that we can assume the DB is already casting the value for us. The enum type needs additional information to perform casting, and needs a subtype. I've opted not to call `super` in `cast`, as we have a known set of types which we accept there, and the subtype likely doesn't accept them (symbol -> integer doesn't make sense) Close #23190
-
- 13 8月, 2015 1 次提交
-
-
由 Yves Senn 提交于
As described in the "Follow Coding Conventions" section in our contribution guide (http://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions) we favor `assert_not` over `refute`. While we don't usually make stylistic changes on it's own I opted to do it in this case. The reason being that test cases are usually copied as a starting point for new tests. This results in a spread of `refute` in files that have been using it already.
-
- 03 7月, 2015 1 次提交
-
-
由 eileencodes 提交于
After 908cfef6 was introduced fixtures that did not set an enum would return nil instead of the default enum value. The fixtures should assume the default if a different enum is not defined. The change checks first if the enum is defined in the fixture before setting it based on the fixture.
-
- 12 6月, 2015 1 次提交
-
-
由 Igor Kapkov 提交于
Fixes #17511 and #17415
-
- 28 5月, 2015 1 次提交
-
-
由 George Claghorn 提交于
Currently, values for columns backing Active Record enums must be specified as integers in test fixtures: awdr: title: "Agile Web Development with Rails" status: 2 rfr: title: "Ruby for Rails" status: <%= Book.statuses[:proposed] %> This is potentially confusing, since enum values are typically specified as symbols or strings in application code. To resolve the confusion, this change permits the use of symbols or strings to specify enum values: awdr: status: :published It is compatible with fixtures that specify enum values as integers.
-
- 05 3月, 2015 1 次提交
-
-
由 keepcosmos 提交于
-