1. 21 1月, 2015 2 次提交
    • S
      Introduce `ActiveRecord::Base#accessed_fields` · be9b6803
      Sean Griffin 提交于
      This method can be used to see all of the fields on a model which have
      been read. This can be useful during development mode to quickly find
      out which fields need to be selected. For performance critical pages, if
      you are not using all of the fields of a database, an easy performance
      win is only selecting the fields which you need. By calling this method
      at the end of a controller action, it's easy to determine which fields
      need to be selected.
      
      While writing this, I also noticed a place for an easy performance win
      internally which I had been wanting to introduce. You cannot mutate a
      field which you have not read. Therefore, we can skip the calculation of
      in place changes if we have never read from the field. This can
      significantly speed up methods like `#changed?` if any of the fields
      have an expensive mutable type (like `serialize`)
      
      ```
      Calculating -------------------------------------
       #changed? with serialized column (before)
                             391.000  i/100ms
       #changed? with serialized column (after)
                               1.514k i/100ms
      -------------------------------------------------
       #changed? with serialized column (before)
                                4.243k (± 3.7%) i/s -     21.505k
       #changed? with serialized column (after)
                               16.789k (± 3.2%) i/s -     84.784k
      ```
      be9b6803
    • A
      TransactionManager should call rollback records · 2e85224f
      Arthur Neves 提交于
      2e85224f
  2. 20 1月, 2015 3 次提交
  3. 19 1月, 2015 4 次提交
    • S
      Add an `:if_exists` option to `drop_table` · 48e99a45
      Stefan Kanev 提交于
      If set to `if_exists: true`, it generates a statement like:
      
          DROP TABLE IF EXISTS posts
      
      This syntax is supported in the popular SQL servers, that is (at least)
      SQLite, PostgreSQL, MySQL, Oracle and MS SQL Sever.
      
      Closes #16366.
      48e99a45
    • R
      Remove unused accessor · 8e20737c
      Ryuta Kamizono 提交于
      8e20737c
    • R
      Should escape regexp wildcard character `.` · bd78cc88
      Ryuta Kamizono 提交于
      `.` is regexp meta character. It should be escape for `assert_match`
      correctly.
      bd78cc88
    • S
      Don't calculate in-place changes on attribute assignment · ea721d70
      Sean Griffin 提交于
      When an attribute is assigned, we determine if it was already marked as
      changed so we can determine if we need to clear the changes, or mark it
      as changed. Since this only affects the `attributes_changed_by_setter`
      hash, in-place changes are irrelevant to this process. Since calculating
      in-place changes can be expensive, we can just skip it here.
      
      I also added a test for the only edge case I could think of that would
      be affected by this change.
      ea721d70
  4. 18 1月, 2015 2 次提交
  5. 16 1月, 2015 1 次提交
  6. 15 1月, 2015 3 次提交
  7. 11 1月, 2015 3 次提交
  8. 10 1月, 2015 4 次提交
    • N
      Use IO::NULL always · 69e365d2
      Nobuyoshi Nakada 提交于
      69e365d2
    • R
      Switch Secure Token generation to Base58 · 47316fee
      robertomiranda 提交于
      Update Secure Token Doc [ci skip]
      
      remove require securerandom, core_ext/securerandom already do that ref 7e006057
      47316fee
    • S
      Properly copy nested bind values from subqueried relations · ec475547
      Sean Griffin 提交于
      This is cropping up all over the place. After a brief dive, I'm really
      not sure why we have `arel.bind_values` at all. A cursory grep didn't
      reveal where they're actually being assigned (it's definitely in AR, not
      in Arel). I'd like to dig further into it, as I'm fairly certain we
      don't actually need it, we just need a way for the predicate builder to
      communicate merged binds upstream.
      
      Fixes #18414
      ec475547
    • S
      Properly persist `lock_version` as 0 if the DB has no default · 13772bfa
      Sean Griffin 提交于
      The reason this bug occured is that we never actually check to see if
      this column has changed from it's default, since it was never assigned
      and is not mutable.
      
      It appears I was wrong in b301c402, with
      my statement of "there is no longer a case where a given value would
      differ from the default, but would not already be marked as changed."
      
      However, I chose not to revert the deletion of
      `initialize_internals_callback` from that commit, as I think a solution
      closer to where the problem lies is less likely to get erroneously
      removed. I'm not super happy with this solution, but it mirrors what is
      being done in `_update_record`, and a fix for one should work for the
      other.
      
      I toyed with the idea of changing the definition of `changed?` on the
      type to `changed_in_place?`. If we type cast the raw value, it'll break
      a test about updating not modifying the lock column if nothing else was
      changed. We could have the definition check if `raw_old_value` is `nil`,
      but this feels fragile and less intention revealing. It would, however,
      have the benefit of cleaning up old data that incorrectly persisted as
      `nil`.
      
      Fixes #18422
      13772bfa
  9. 08 1月, 2015 1 次提交
    • B
      Fix count on a separate connection (fixes #18359) · 82486280
      brainopia 提交于
      Previosly count and other AR calculations would convert
      column_name_for_operation to sql on a default Arel::Table.engine
      (AR::Base) connection. That could lead to trouble if current
      model has a connection to a different adapter or Base connection
      is inaccessible.
      82486280
  10. 06 1月, 2015 5 次提交
  11. 05 1月, 2015 9 次提交
  12. 04 1月, 2015 3 次提交