1. 10 7月, 2020 1 次提交
  2. 20 6月, 2020 3 次提交
  3. 13 5月, 2020 1 次提交
  4. 08 4月, 2020 1 次提交
  5. 27 3月, 2020 1 次提交
  6. 18 3月, 2020 1 次提交
    • A
      Use non-exist enum string to get unrelated record in My SQL · 93b8c24f
      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>
      93b8c24f
  7. 27 12月, 2019 1 次提交
  8. 25 12月, 2019 1 次提交
    • Y
      Allow AR::Enum definitions with boolean values · f4fbdb1b
      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.
      f4fbdb1b
  9. 30 7月, 2019 1 次提交
    • R
      Add `silence_warnings` for defining 'not_' prefix enum elements · fff120c7
      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
      ```
      fff120c7
  10. 01 7月, 2019 1 次提交
  11. 27 2月, 2019 2 次提交
  12. 04 12月, 2018 1 次提交
  13. 24 11月, 2018 1 次提交
  14. 08 11月, 2018 1 次提交
  15. 10 10月, 2018 1 次提交
    • A
      Raise on invalid definition values · 9b964011
      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
      9b964011
  16. 26 1月, 2018 3 次提交
  17. 28 11月, 2017 1 次提交
  18. 23 8月, 2017 1 次提交
    • Y
      Load both `:authors` and `:author_addresses` to keep data integrity · 43c6a683
      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.
      43c6a683
  19. 16 8月, 2017 1 次提交
  20. 20 7月, 2017 1 次提交
  21. 02 7月, 2017 1 次提交
  22. 01 7月, 2017 1 次提交
  23. 31 5月, 2017 1 次提交
  24. 07 5月, 2017 1 次提交
  25. 03 5月, 2017 1 次提交
  26. 12 9月, 2016 1 次提交
  27. 07 8月, 2016 1 次提交
  28. 31 7月, 2016 1 次提交
  29. 24 6月, 2016 1 次提交
  30. 23 1月, 2016 1 次提交
    • S
      Use the database type to deserialize enum · 67c17190
      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
      67c17190
  31. 13 8月, 2015 1 次提交
  32. 03 7月, 2015 1 次提交
    • E
      Use default model enum in fixtures if not defined · eff3a317
      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.
      eff3a317
  33. 12 6月, 2015 1 次提交
  34. 28 5月, 2015 1 次提交
    • G
      Resolve enums in test fixtures · 908cfef6
      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.
      908cfef6
  35. 05 3月, 2015 1 次提交