1. 18 10月, 2019 1 次提交
  2. 20 9月, 2019 1 次提交
  3. 09 9月, 2019 1 次提交
  4. 29 8月, 2019 2 次提交
  5. 23 8月, 2019 1 次提交
  6. 17 8月, 2019 1 次提交
  7. 30 7月, 2019 3 次提交
  8. 28 7月, 2019 2 次提交
  9. 27 7月, 2019 1 次提交
  10. 26 7月, 2019 1 次提交
  11. 23 7月, 2019 2 次提交
  12. 09 7月, 2019 2 次提交
  13. 17 6月, 2019 1 次提交
  14. 15 6月, 2019 1 次提交
  15. 14 6月, 2019 1 次提交
    • J
      Make ActiveRecord `ConnectionPool.connections` thread-safe. (#36473) · 05ee6624
      jeffdoering 提交于
      * Make ActiveRecord `ConnectionPool.connections` thread-safe.
      
      ConnectionPool documentation is clear on the need to synchronize
      access to @connections but also states that public methods do not
      require synchronization. Existing code exposed @connections
      directly via attr_reader. The fix uses synchronize() to lock
      @connections then returns a copy to the caller using Array.dup().
      
      Includes comments on the connections method that thread-safe access
      to the connections array does not imply thread-safety of accessing
      methods on the actual connections.
      
      Adds a test-case that modifies the pool using a supported method
      in one thread  while a second thread accesses pool.connections.
      The test fails without this patch.
      
      Fixes #36465.
      
      * Update activerecord/test/cases/connection_pool_test.rb
      
      [jeffdoering + Rafael Mendonça França]
      05ee6624
  16. 05 6月, 2019 1 次提交
  17. 03 6月, 2019 1 次提交
  18. 02 6月, 2019 1 次提交
  19. 27 4月, 2019 1 次提交
  20. 25 4月, 2019 2 次提交
  21. 19 4月, 2019 1 次提交
    • R
      Deprecate `where.not` working as NOR and will be changed to NAND in Rails 6.1 · 12a9664f
      Ryuta Kamizono 提交于
      `where.not` with polymorphic association is partly fixed incidentally at
      213796fb (refer #33493, #26207, #17010, #16983, #14161), and I've added
      test case e9ba12f7 to avoid lose that fix accidentally in the future.
      
      In Rails 5.2, `where.not(polymorphic: object)` works as expected as
      NAND, but `where.not(polymorphic_type: object.class.polymorphic_name,
      polymorphic_id: object.id)` still unexpectedly works as NOR.
      
      To will make `where.not` working desiredly as NAND in Rails 6.1, this
      deprecates `where.not` working as NOR. If people want to continue NOR
      conditions, we'd encourage to them to `where.not` each conditions
      manually.
      
      ```ruby
      all = [treasures(:diamond), treasures(:sapphire), cars(:honda), treasures(:sapphire)]
      assert_equal all, PriceEstimate.all.map(&:estimate_of)
      ```
      
      In Rails 6.0:
      
      ```ruby
      sapphire = treasures(:sapphire)
      
      nor = all.reject { |e|
        e.estimate_of_type == sapphire.class.polymorphic_name
      }.reject { |e|
        e.estimate_of_id == sapphire.id
      }
      assert_equal [cars(:honda)], nor
      
      without_sapphire = PriceEstimate.where.not(
        estimate_of_type: sapphire.class.polymorphic_name, estimate_of_id: sapphire.id
      )
      assert_equal nor, without_sapphire.map(&:estimate_of)
      ```
      
      In Rails 6.1:
      
      ```ruby
      sapphire = treasures(:sapphire)
      
      nand = all - [sapphire]
      assert_equal [treasures(:diamond), cars(:honda)], nand
      
      without_sapphire = PriceEstimate.where.not(
        estimate_of_type: sapphire.class.polymorphic_name, estimate_of_id: sapphire.id
      )
      assert_equal nand, without_sapphire.map(&:estimate_of)
      ```
      
      Resolves #31209.
      12a9664f
  22. 17 4月, 2019 1 次提交
    • L
      Add collection cache versioning · 4f2ac80d
      Lachlan Sylvester 提交于
      Cache versioning enables the same cache key to be reused when the object
      being cached changes by moving the volatile part of the cache key out of
      the cache key and into a version that is embedded in the cache entry.
      
      This is already occurring when the object being cached is an
      `ActiveRecord::Base`, but when caching an `ActiveRecord::Relation`
      we are currently still putting the volatile information (max updated at
      and count) as part of the cache key.
      
      This PR moves the volatile part of the relations `cache_key` into the
      `cache_version` to support recycling cache keys for
      `ActiveRecord::Relation`s.
      4f2ac80d
  23. 16 4月, 2019 2 次提交
    • R
      Fix dirty tracking after rollback. · 63ff495b
      Ryuta Kamizono 提交于
      Currently the rollback only restores primary key value, `new_record?`,
      `destroyed?`, and `frozen?`. Since the `save` clears current dirty
      attribute states, retrying save after rollback will causes no change
      saved if partial writes is enabled (by default).
      
      This makes `remember_transaction_record_state` remembers original values
      then restores dirty attribute states after rollback.
      
      Fixes #15018.
      Fixes #30167.
      Fixes #33868.
      Fixes #33443.
      Closes #33444.
      Closes #34504.
      63ff495b
    • R
      Add CHANGELOG entry for d1107f4d · 20b94af9
      Ryuta Kamizono 提交于
      [ci skip]
      20b94af9
  24. 15 4月, 2019 1 次提交
    • Y
      make change_column_comment and change_table_comment invertible · 1fe71ebd
      Yoshiyuki Kinjo 提交于
      We can revert migrations using `change_column_comment` or
      `change_table_comment` at current master.
      However, results are not what we expect: comments are remained in new
      status.
      This change tells previous comment to these methods in a way like
      `change_column_default`.
      1fe71ebd
  25. 12 4月, 2019 1 次提交
    • R
      Don't call after_commit callbacks despite a record isn't saved · 9252da96
      Ryuta Kamizono 提交于
      Regardless of a record isn't saved (e.g. validation is failed),
      `after_commit` / `after_rollback` callbacks are invoked for now.
      
      To fix the issue, this adds a record to the current transaction only
      when a record is actually saved.
      
      Fixes #29747.
      Closes #29833.
      9252da96
  26. 07 4月, 2019 1 次提交
    • R
      Raise `ArgumentError` for invalid `:limit` and `:precision` like as other options · 20da6c7e
      Ryuta Kamizono 提交于
      When I've added new `:size` option in #35071, I've found that invalid
      `:limit` and `:precision` raises `ActiveRecordError` unlike other
      invalid options.
      
      I think that is hard to distinguish argument errors and statement
      invalid errors since the `StatementInvalid` is a subclass of the
      `ActiveRecordError`.
      
      https://github.com/rails/rails/blob/c9e4c848eeeb8999b778fa1ae52185ca5537fffe/activerecord/lib/active_record/errors.rb#L103
      
      ```ruby
      begin
        # execute any migration
      rescue ActiveRecord::StatementInvalid
        # statement invalid
      rescue ActiveRecord::ActiveRecordError, ArgumentError
        # `ActiveRecordError` except `StatementInvalid` is maybe an argument error
      end
      ```
      
      I'd say this is the inconsistency worth fixing.
      
      Before:
      
      ```ruby
      add_column :items, :attr1, :binary,   size: 10      # => ArgumentError
      add_column :items, :attr2, :decimal,  scale: 10     # => ArgumentError
      add_column :items, :attr3, :integer,  limit: 10     # => ActiveRecordError
      add_column :items, :attr4, :datetime, precision: 10 # => ActiveRecordError
      ```
      
      After:
      
      ```ruby
      add_column :items, :attr1, :binary,   size: 10      # => ArgumentError
      add_column :items, :attr2, :decimal,  scale: 10     # => ArgumentError
      add_column :items, :attr3, :integer,  limit: 10     # => ArgumentError
      add_column :items, :attr4, :datetime, precision: 10 # => ArgumentError
      ```
      20da6c7e
  27. 05 4月, 2019 1 次提交
    • R
      Association loading isn't to be affected by scoping consistently · 17f2f305
      Ryuta Kamizono 提交于
      Follow-up of 5c71000d, #29834, and #30271.
      
      Currently, preloading and eager loading are not to be affected by
      scoping, with the exception of `unscoped`.
      
      But non eager loaded association access is still affected by scoping.
      
      Although this is a breaking change, the association loading will work
      consistently whether preloaded / eager loaded or not.
      
      Before:
      
      ```ruby
      Post.where("1=0").scoping do
        Comment.find(1).post                   # => nil
        Comment.preload(:post).find(1).post    # => #<Post id: 1, ...>
        Comment.eager_load(:post).find(1).post # => #<Post id: 1, ...>
      end
      ```
      
      After:
      
      ```ruby
      Post.where("1=0").scoping do
        Comment.find(1).post                   # => #<Post id: 1, ...>
        Comment.preload(:post).find(1).post    # => #<Post id: 1, ...>
        Comment.eager_load(:post).find(1).post # => #<Post id: 1, ...>
      end
      ```
      
      Fixes #34638.
      Fixes #35398.
      17f2f305
  28. 03 4月, 2019 5 次提交