1. 25 12月, 2016 1 次提交
  2. 23 12月, 2016 1 次提交
  3. 10 12月, 2016 1 次提交
  4. 09 12月, 2016 1 次提交
  5. 24 11月, 2016 2 次提交
    • D
      Add test for collection *_ids= setter when association primary key set · 93550206
      Dominic Cleal 提交于
      Fixes casting of IDs to the data type of the association primary key,
      rather than then the data type of the model's primary key. (Tests use a
      string primary key on the association, rather than an int.)
      
      Tests issue #20995
      93550206
    • D
      Restore RecordNotFound when *_ids= can't find records by ID · 15e2da65
      Dominic Cleal 提交于
      9c9fb19b changed the behaviour of the _ids= setters for associations to
      raise an AssociationTypeMismatch when unknown IDs are given:
      
          Class: <ActiveRecord::AssociationTypeMismatch>
          Message: <"Developer(#43811860) expected, got NilClass(#16732720)">
      
      This restores the original ActiveRecord::RecordNotFound exception with a
      much clearer error message:
      
          Class: <ActiveRecord::RecordNotFound>
          Message: <"Couldn't find all Developers with 'id': (1, -9999) [WHERE \"contracts\".\"company_id\" = ?] (found 1 results, but was looking for 2)">
      
      Fixes #25719
      15e2da65
  6. 22 11月, 2016 1 次提交
    • Y
      Introduce `reload_<association>` reader for singular associations. · 0e995713
      Yves Senn 提交于
      This patch brings back the functionality of passing true to the
      association proxy. The behavior was deprecated with #20888 and scheduled
      for removal in Rails 5.1.
      
      The deprecation mentioned that instead of `Article.category(true)` one
      should use `article#reload.category`. Unfortunately the alternative does
      not expose the same behavior as passing true to the reader
      did. Specifically reloading the parent record throws unsaved changes and
      other caches away. Passing true only affected the association.
      
      This is problematic and there is no easy workaround. I propose to bring
      back the old functionality by introducing this new reader method for
      singular associations.
      0e995713
  7. 13 11月, 2016 1 次提交
    • R
      Respect new records for `CollectionProxy#uniq` · 0ec967aa
      Ryuta Kamizono 提交于
      Currently if `CollectionProxy` has more than one new record,
      `CollectionProxy#uniq` result is incorrect.
      
      And `CollectionProxy#uniq` was aliased to `distinct` in a1bb6c8b.
      But the `uniq` method and the `SELECT DISTINCT` method are different
      methods. The doc in `CollectionProxy` is for the `SELECT DISTINCT`
      method, not for the `uniq` method.
      
      Therefore, reverting the alias in `CollectionProxy` to fix the
      inconsistency and to have the both methods.
      0ec967aa
  8. 03 11月, 2016 1 次提交
  9. 02 11月, 2016 1 次提交
    • S
      Allow `autosave: true` to be used with inverse of · c7adc610
      Sean Griffin 提交于
      With the changes in #25337, double save bugs are pretty much impossible,
      so we can just lift this restriction with pretty much no change. There
      were a handful of cases where we were relying on specific quirks in
      tests that had to be updated. The change to has_one associations was due
      to a particularly interesting test where an autosaved has_one
      association was replaced with a new child, where the child failed to
      save but the test wanted to check that the parent id persisted to `nil`.
      
      I think this is almost certainly the wrong behavior, and I may change
      that behavior later. But ultimately the root cause was because we never
      remove the parent in memory when nullifying the child. This makes #23197
      no longer needed, but it is what we'll do to fix some issues on 5.0
      
      Close #23197
      c7adc610
  10. 29 10月, 2016 1 次提交
  11. 27 10月, 2016 2 次提交
    • M
      Fix HABTM associations join table resolver bug on constants and symbols · 94821b4b
      Mehmet Emin İNAÇ 提交于
      Using Constant and symbol class_name option for associations are valid but raises exception on HABTM associations.
      There was a test case which tries to cover symbol class_name usage but doesn't cover correctly. Fixed both symbol usage and constant usage as well.
      
      These are all working as expected now;
      ```
        has_and_belongs_to_many :foos, class_name: 'Foo'
        has_and_belongs_to_many :foos, class_name: :Foo
        has_and_belongs_to_many :foos, class_name: Foo
      ```
      
      Closes #23767
      94821b4b
    • X
      let Regexp#match? be globally available · 56832e79
      Xavier Noria 提交于
      Regexp#match? should be considered to be part of the Ruby core library. We are
      emulating it for < 2.4, but not having to require the extension is part of the
      illusion of the emulation.
      56832e79
  12. 22 10月, 2016 1 次提交
  13. 10 10月, 2016 1 次提交
  14. 30 9月, 2016 1 次提交
    • S
      Don't skip in-memory insertion of associations when loaded in validate · 268a5bb0
      Sean Griffin 提交于
      This was caused by 6d0d83a3. While the
      bug it's trying to fix is handled if the association is loaded in an
      after_(create|save) callback, it doesn't handle any cases that load the
      association before the persistence takes place (validation, or before_*
      filters). Instead of caring about the timing of persistence, we can just
      ensure that we're not double adding the record instead.
      
      The test from that commit actually broke, but it was not because the bug
      has been re-introduced. It was because `Bulb` in our test suite is doing
      funky things that look like STI but isn't STI, so equality comparison
      didn't happen as the loaded model was of a different class.
      
      Fixes #26661.
      268a5bb0
  15. 17 9月, 2016 1 次提交
  16. 31 8月, 2016 1 次提交
    • S
      Ensure that inverse associations are set before running callbacks · caa178c1
      Sean Griffin 提交于
      If a parent association was accessed in an `after_find` or
      `after_initialize` callback, it would always end up loading the
      association, and then immediately overwriting the association we just
      loaded. If this occurred in a way that the parent's `current_scope` was
      set to eager load the child, this would result in an infinite loop and
      eventually overflow the stack.
      
      For records that are created with `.new`, we have a mechanism to
      perform an action before the callbacks are run. I've introduced the same
      code path for records created with `instantiate`, and updated all code
      which sets inverse instances on newly loaded associations to use this
      block instead.
      
      Fixes #26320.
      caa178c1
  17. 26 8月, 2016 1 次提交
    • J
      Don't unnecessarily load a belongs_to when saving. · a94fe297
      James Coleman 提交于
      Previously, if the the association was previously loaded and then
      the foreign key changed by itself, a #save call would trigger a
      load of the new associated record during autosave. This is unnecessary
      and the autosave code (in that case) didn't use the loaded record
      anyways.
      a94fe297
  18. 16 8月, 2016 4 次提交
    • R
      Finder bang method should call non bang method · 9d008884
      Ryuta Kamizono 提交于
      Otherwise CollectionProxy's bang methdos cannot respect dirty target.
      9d008884
    • R
      Fix inconsistent the signature of finder methods for collection association · 46380674
      Ryuta Kamizono 提交于
      `#second`, `#third`, etc finder methods was added in 03855e79.
      But the signature of these methods is inconsistent with the original
      finder methods. And also the signature of `#first` and `#last` methods
      is different from the original. This commit fixes the inconsistency.
      46380674
    • M
      Fix count which would sometimes force a DISTINCT · 0aae7806
      Maxime Lapointe 提交于
      The current behaviour of checking if there is a LEFT OUTER JOIN arel
      node to detect if we are doing eager_loading is wrong. This problem
      wasn't frequent before as only some pretty specific cases would add
      a LEFT OUTER JOIN arel node. However, the recent new feature
      left_outer_joins also add this node and made this problem happen
      frequently.
      
      Since in the perform_calculation function, we don't have access to
      eager_loading information, I had to extract the logic for the distinct
      out to the calculate method.
      
      As I was in the file for left_outer_join tests, I fixed a few that had
      bugs and I replaced some that were really weak with something that
      will catch more issues.
      
      In relation tests, the first test I changed would have failed if it
      had validated the hash returned by count instead of just checking how
      many pairs were in it. This is because this merge of join currently
      transforms the join node into an outer join node, which then made
      count do a distinct. So before this change, the return was
      {1=>1, 4=>1, 5=>1}.
      0aae7806
    • R
      Add three new rubocop rules · 55f9b812
      Rafael Mendonça França 提交于
      Style/SpaceBeforeBlockBraces
      Style/SpaceInsideBlockBraces
      Style/SpaceInsideHashLiteralBraces
      
      Fix all violations in the repository.
      55f9b812
  19. 14 8月, 2016 2 次提交
  20. 10 8月, 2016 1 次提交
  21. 07 8月, 2016 6 次提交
  22. 30 7月, 2016 1 次提交
  23. 26 7月, 2016 2 次提交
  24. 25 7月, 2016 1 次提交
  25. 24 7月, 2016 1 次提交
  26. 20 7月, 2016 1 次提交
  27. 18 7月, 2016 1 次提交
  28. 10 7月, 2016 1 次提交