1. 23 11月, 2017 1 次提交
  2. 20 11月, 2017 1 次提交
    • R
      Prevent extra `spawn` to make `klass.all` faster (#29009) · eeaf9cf6
      Ryuta Kamizono 提交于
      These extra `spawn` are called via `klass.all` and `klass.all` is called
      everywhere in the internal. Avoiding the extra `spawn` makes` klass.all`
      30% faster for STI classes.
      
      https://gist.github.com/kamipo/684d03817a8115848cec8e8b079560b7
      
      ```
      Warming up --------------------------------------
             fast relation     4.410k i/100ms
             slow relation     3.334k i/100ms
      Calculating -------------------------------------
             fast relation     47.373k (± 5.2%) i/s -    238.140k in   5.041836s
             slow relation     35.757k (±15.9%) i/s -    176.702k in   5.104625s
      
      Comparison:
             fast relation:    47373.2 i/s
             slow relation:    35756.7 i/s - 1.32x  slower
      ```
      eeaf9cf6
  3. 18 11月, 2017 1 次提交
    • M
      Improve AR connection fork safety · f32cff55
      Matthew Draper 提交于
      Use whatever adapter-provided means we have available to ensure forked
      children don't send quit/shutdown/goodbye messages to the server on
      connections that belonged to their parent.
      f32cff55
  4. 17 11月, 2017 1 次提交
    • R
      Avoid creating extra `relation` and `build_arel` in `_create_record` and `_update_record` (#29999) · bbae710a
      Ryuta Kamizono 提交于
      Currently `_create_record` and `_update_record` in `Persistence` are
      creating extra `unscoped` and calling `build_arel` in the relation. But
      `compile_insert` and `compile_update` can be done without those
      expensive operation for `SelectManager` creation. So I moved the
      implementation to `Persistence` to avoid creating extra relation and
      refactored to avoid calling `build_arel`.
      
      https://gist.github.com/kamipo/8ed73d760112cfa5f6263c9413633419
      
      Before:
      
      ```
      Warming up --------------------------------------
            _update_record   150.000  i/100ms
      Calculating -------------------------------------
            _update_record      1.548k (±12.3%) i/s -      7.650k in   5.042603s
      ```
      
      After:
      
      ```
      Warming up --------------------------------------
            _update_record   201.000  i/100ms
      Calculating -------------------------------------
            _update_record      2.002k (±12.8%) i/s -      9.849k in   5.027681s
      ```
      
      30% faster for STI classes.
      bbae710a
  5. 15 11月, 2017 2 次提交
  6. 14 11月, 2017 4 次提交
    • N
      Update `exists?` documentation · 67dbfc69
      Nikolai B 提交于
      Make it clear that `exists?` can be chained onto a relation
      67dbfc69
    • Y
      Add `environment` as dependency of `load_config` (#31135) · b6d5e463
      Yuji Yaginuma 提交于
      Currently the environment is not loaded in some db tasks.
      Therefore, if use encrypted secrets values in `database.yml`,
      `read_encrypted_secrets` will not be true, so the value can not be
      used correctly.
      
      To fix this, added `environment` as dependency of `load_config`.
      It also removes explicit `environment` dependencies that are no longer
      needed.
      
      Fixes #30717
      b6d5e463
    • S
      Properly cast input in `update_all` · 68fe6b08
      Sean Griffin 提交于
      The documentation claims that given values go through "normal AR type
      casting and serialization", which to me implies
      `serialize(cast(value))`, not just serialization. The docs were changed
      to use this wording in #22492. The tests I cited in that PR (which is
      the same test modified in this commit), is worded in a way that implies
      it should be using `cast` as well.
      
      It's possible that I originally meant "normal type casting" to imply
      just the call to `serialize`, but given that `update_all(archived:
      params['archived'])` seems to be pretty common, I'm inclined to make
      this change as long as no tests are broken from it.
      68fe6b08
    • J
      Do not use `Arel.star` when `ignored_columns` · 6acde957
      Jon Moss 提交于
      If there are any ignored columns, we will now list out all columns we
      want to be returned from the database.
      
      Includes a regression test.
      6acde957
  7. 13 11月, 2017 1 次提交
  8. 11 11月, 2017 3 次提交
    • R
      Raise `TransactionTimeout` when lock wait timeout exceeded for PG adapter · 4a65dfcb
      Ryuta Kamizono 提交于
      Follow up of #30360.
      4a65dfcb
    • R
      Add missing autoload `Type` (#31123) · 24b59434
      Ryuta Kamizono 提交于
      Attribute modules (`Attribute`, `Attributes`, `AttributeSet`) uses
      `Type`, but referencing `Type` before the modules still fail.
      
      ```
      % ./bin/test -w test/cases/attribute_test.rb -n test_with_value_from_user_validates_the_value
      Run options: -n test_with_value_from_user_validates_the_value --seed 31876
      
      E
      
      Error:
      ActiveModel::AttributeTest#test_with_value_from_user_validates_the_value:
      NameError: uninitialized constant ActiveModel::AttributeTest::Type
          /Users/kamipo/src/github.com/rails/rails/activemodel/test/cases/attribute_test.rb:233:in `block in <class:AttributeTest>'
      
      bin/test test/cases/attribute_test.rb:232
      
      Finished in 0.002985s, 335.0479 runs/s, 335.0479 assertions/s.
      1 runs, 1 assertions, 0 failures, 1 errors, 0 skips
      ```
      
      Probably we need more autoloading at least `Type`.
      24b59434
    • R
      Relation merging should keep joining order · 4528dd63
      Ryuta Kamizono 提交于
      `joins_values.partition` will break joins values order. It should be
      kept as user intended order.
      
      Fixes #15488.
      4528dd63
  9. 10 11月, 2017 4 次提交
  10. 09 11月, 2017 14 次提交
  11. 08 11月, 2017 2 次提交
  12. 07 11月, 2017 3 次提交
    • R
      Remove useless `associated_records_by_owner` · 3f1695bb
      Ryuta Kamizono 提交于
      `associated_records_by_owner` had returned customizing result before
      calling `associate_records_to_owner` for through association subclasses.
      Since #22115, `associate_records_to_owner` is called in the method and
      not returned owner and result pairs. Removing the method will reduce
      method call and block call nesting.
      3f1695bb
    • B
      Fix `bin/rails db:migrate` with specified `VERSION` · 90fe2a42
      bogdanvlviv 提交于
      Ensure that `bin/rails db:migrate` with specified `VERSION` reverts
      all migrations only if `VERSION` is `0`.
      Raise error if target migration doesn't exist.
      90fe2a42
    • K
      Properly check transaction in persistence · 01c70324
      Keenan Brock 提交于
      ```
      [NoMethodError]: undefined method `state' for nil:NilClass  Method:[rescue in block in refresh]
      ```
      
      In `within_new_transaction`, there is the possibility that
      `begin_transaction` returns a `nil`. (i.e.: so `transaction = nil`)
      So this method is checking `transaction` for nil in 2 spots.
      
      Unfortunately, there is one line that is not checking `transaction` for `nil`
      That line, `commit_transaction`, throws an exception for us in AR 5.0.0.1
      
      The problem with the method is finally realized in the error checking itself.
      it calls `transaction.state` (i.e.: nil.state) and that is the final exception
      raised.
      
      The actual underlying (user) issue is hidden by this line.
      
      Solution is test transaction for nil.
      01c70324
  13. 06 11月, 2017 3 次提交