1. 23 9月, 2016 1 次提交
    • P
      Return true if attribute is not changed for update_attribute · 730e99af
      Prathamesh Sonpatki 提交于
      - If the attribute is not changed, then update_attribute does not run
        SQL query, this effectively means that no change was made to the
        attribute.
      - This change was made in https://github.com/rails/rails/commit/0fcd4cf5
        to avoid a SQL call.
      - But the change resulted into `nil` being returned when there was no
        change in the attribute value.
      - This commit corrects the behavior to return true if there is no change
        in attribute value. This is same as previous behavior of Rails 4.2
        plus benefit of no additional SQL call.
      - Fixes #26593.
      730e99af
  2. 16 8月, 2016 1 次提交
  3. 10 8月, 2016 1 次提交
  4. 07 8月, 2016 3 次提交
  5. 03 2月, 2016 1 次提交
  6. 15 12月, 2015 1 次提交
  7. 07 11月, 2015 2 次提交
    • S
      Fix test failures · 986f79a4
      Sean Griffin 提交于
      The previous commit changes the state of the class, and while we are
      cleaning up the database, I forgot to clean up the class
      986f79a4
    • S
      Ensure `#reset_column_information` clears child classes as well · 9deb6aba
      Sean Griffin 提交于
      I've added a redundant test for this under the attributes API as well,
      as that also causes this bug to manifest through public API (and
      demonstrates that calling `reset_column_information` on the child
      classes would be insufficient)
      
      Since children of a class should always share a table with their parent,
      just reloading the schema from the cache should be sufficient here.
      `reload_schema_from_cache` should probably become public and
      `# :nodoc:`, but I'd rather avoid the git churn here.
      
      Fixes #22057
      9deb6aba
  8. 03 11月, 2015 1 次提交
  9. 05 10月, 2015 1 次提交
  10. 06 9月, 2015 1 次提交
  11. 24 8月, 2015 1 次提交
  12. 29 4月, 2015 1 次提交
  13. 31 3月, 2015 1 次提交
    • K
      use Model.reset_column_information to clear table cache connection wide. · bf6a33fd
      Kuldeep Aggarwal 提交于
          `widgets` table is being created in `primary_keys_test.rb` for PostgreSQLAdapter, MysqlAdapter, Mysql2Adapter
          and it makes test to fail earlier.
      
          Before:
            `bundle exec rake mysql2:test`
      
          ```
          Finished in 127.287669s, 35.5258 runs/s, 97.8885 assertions/s.
      
            1) Error:
          PersistenceTest::SaveTest#test_save_touch_false:
          ActiveModel::UnknownAttributeError: unknown attribute 'name' for #<Class:0x0000000a7d6ef0>.
              /home/kd/projects/kd-rails/activerecord/lib/active_record/attribute_assignment.rb:36:in `rescue in _assign_attribute'
              /home/kd/projects/kd-rails/activerecord/lib/active_record/attribute_assignment.rb:34:in `_assign_attribute'
              /home/kd/projects/kd-rails/activemodel/lib/active_model/attribute_assignment.rb:40:in `block in _assign_attributes'
              /home/kd/projects/kd-rails/activemodel/lib/active_model/attribute_assignment.rb:39:in `each'
              /home/kd/projects/kd-rails/activemodel/lib/active_model/attribute_assignment.rb:39:in `_assign_attributes'
              /home/kd/projects/kd-rails/activerecord/lib/active_record/attribute_assignment.rb:26:in `_assign_attributes'
              /home/kd/projects/kd-rails/activemodel/lib/active_model/attribute_assignment.rb:33:in `assign_attributes'
              /home/kd/projects/kd-rails/activerecord/lib/active_record/core.rb:293:in `initialize'
              /home/kd/projects/kd-rails/activerecord/lib/active_record/inheritance.rb:61:in `new'
              /home/kd/projects/kd-rails/activerecord/lib/active_record/inheritance.rb:61:in `new'
              /home/kd/projects/kd-rails/activerecord/lib/active_record/persistence.rb:50:in `create!'
              /home/kd/projects/kd-rails/activerecord/test/cases/persistence_test.rb:913:in `test_save_touch_false'
      
          4522 runs, 12460 assertions, 0 failures, 1 errors, 4 skips
          ```
      
          After:
            `bundle exec rake mysql2:test`
      
          ```
             Finished in 135.785086s, 33.3026 runs/s, 91.7774 assertions/s.
      
             4522 runs, 12462 assertions, 0 failures, 0 errors, 4 skips
          ```
      bf6a33fd
  14. 17 3月, 2015 1 次提交
    • B
      Closes rails/rails#18864: Renaming transactional fixtures to transactional tests · 09658635
      Brandon Weiss 提交于
      I’m renaming all instances of `use_transcational_fixtures` to
      `use_transactional_tests` and “transactional fixtures” to
      “transactional tests”.
      
      I’m deprecating `use_transactional_fixtures=`. So anyone who is
      explicitly setting this will get a warning telling them to use
      `use_transactional_tests=` instead.
      
      I’m maintaining backwards compatibility—both forms will work.
      `use_transactional_tests` will check to see if
      `use_transactional_fixtures` is set and use that, otherwise it will use
      itself. But because `use_transactional_tests` is a class attribute
      (created with `class_attribute`) this requires a little bit of hoop
      jumping. The writer method that `class_attribute` generates defines a
      new reader method that return the value being set. Which means we can’t
      set the default of `true` using `use_transactional_tests=` as was done
      previously because that won’t take into account anyone using
      `use_transactional_fixtures`. Instead I defined the reader method
      manually and it checks `use_transactional_fixtures`. If it was set then
      it should be used, otherwise it should return the default, which is
      `true`. If someone uses `use_transactional_tests=` then it will
      overwrite the backwards-compatible method with whatever they set.
      09658635
  15. 05 3月, 2015 1 次提交
  16. 18 1月, 2015 1 次提交
  17. 28 12月, 2014 1 次提交
  18. 20 12月, 2014 1 次提交
    • P
      Allow ActiveRecord::Relation#update to run on result of a relation with callbacks and validations · 5ef713c5
      Prathamesh Sonpatki 提交于
      - Right now, there is no method to update multiple records with
        validations and callbacks.
      - Changed the behavior of existing `update` method so that when `id`
        attribute is not given and the method is called on an `Relation`
        object, it will execute update for every record of the `Relation` and
        will run validations and callbacks for every record.
      - Added test case for validating that the callbacks run when `update` is
        called on a `Relation`.
      - Changed test_create_columns_not_equal_attributes test from
        persistence_test to include author_name column on topics table as it
        it used in before_update callback.
      - This change introduces performance issues when a large number of
        records are to be updated because it runs UPDATE query for every
        record of the result. The `update_all` method can be used in that case
        if callbacks are not required because it will only run single UPDATE
        for all the records.
      5ef713c5
  19. 29 11月, 2014 1 次提交
  20. 14 11月, 2014 1 次提交
  21. 06 7月, 2014 1 次提交
    • G
      Fix mysql/mysql2 failing with FK constraint errors · c0310165
      Godfrey Chan 提交于
      One of the author fixture we have ("david") references an author address by ID.
      Since we disable FK checks when inserting fixtures, this is all fine until we
      try to update it, at which point MySQL would complain about the missing row
      referenced by the `author_address_id`.
      
      [Godfrey Chan, Matthew Draper]
      c0310165
  22. 04 7月, 2014 1 次提交
  23. 23 6月, 2014 1 次提交
    • S
      `reload` should fully reload attributes · 3529bbd8
      Sean Griffin 提交于
      `reload` is meant to put a record in the same state it would be if you
      were to do `Post.find(post.id)`. This means we should fully replace the
      attributes hash.
      3529bbd8
  24. 14 6月, 2014 1 次提交
    • S
      Introduce an Attribute object to handle the type casting dance · 6f08db05
      Sean Griffin 提交于
      There's a lot more that can be moved to these, but this felt like a good
      place to introduce the object. Plans are:
      
      - Remove all knowledge of type casting from the columns, beyond a
        reference to the cast_type
      - Move type_cast_for_database to these objects
      - Potentially make them mutable, introduce a state machine, and have
        dirty checking handled here as well
      - Move `attribute`, `decorate_attribute`, and anything else that
        modifies types to mess with this object, not the columns hash
      - Introduce a collection object to manage these, reduce allocations, and
        not require serializing the types
      6f08db05
  25. 13 6月, 2014 1 次提交
  26. 04 6月, 2014 1 次提交
  27. 20 5月, 2014 1 次提交
  28. 14 5月, 2014 1 次提交
  29. 07 5月, 2014 1 次提交
  30. 03 5月, 2014 1 次提交
  31. 19 4月, 2014 1 次提交
  32. 12 3月, 2014 1 次提交
  33. 28 1月, 2014 1 次提交
  34. 27 12月, 2013 1 次提交
  35. 26 6月, 2013 1 次提交
  36. 22 5月, 2013 1 次提交
  37. 12 5月, 2013 1 次提交