1. 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
  2. 22 10月, 2016 1 次提交
  3. 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
  4. 17 9月, 2016 1 次提交
  5. 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
  6. 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
  7. 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
  8. 14 8月, 2016 2 次提交
  9. 10 8月, 2016 1 次提交
  10. 07 8月, 2016 6 次提交
  11. 30 7月, 2016 1 次提交
  12. 26 7月, 2016 2 次提交
  13. 25 7月, 2016 1 次提交
  14. 24 7月, 2016 1 次提交
  15. 20 7月, 2016 1 次提交
  16. 18 7月, 2016 1 次提交
  17. 10 7月, 2016 1 次提交
  18. 02 7月, 2016 1 次提交
  19. 13 6月, 2016 1 次提交
  20. 09 6月, 2016 1 次提交
  21. 31 5月, 2016 1 次提交
    • S
      Exists shouldn't error when used with `includes` · 02da8aea
      Sean Griffin 提交于
      Currently `exists?` does some hackery where it assumes that we can join
      onto anything that we passed to `eager_load` or `includes`, which
      doesn't work if we are joining onto a polymorphic association.
      
      Actually figuring out if we want to include something would require
      knowledge deep within the join dependency module, which is hard to pull
      up. The simplest solution is just to pass a flag down that says we're
      not actually going to try to eager load any of the data. It's not the
      solution I'd like, but that code really needs to be untangled before we
      can do much with it.
      
      This is another attempt at 6d5b1fdf which should address the concerns
      that led to reverting it in 4ecabed2.
      02da8aea
  22. 27 5月, 2016 1 次提交
  23. 19 5月, 2016 1 次提交
  24. 13 5月, 2016 2 次提交
  25. 29 4月, 2016 1 次提交
  26. 06 4月, 2016 1 次提交
    • L
      Fix undefined method `owners' for NullPreloader:Class · cb4f6875
      Ladislav Smola 提交于
      * Fix undefined method `owners' for NullPreloader:Class
      
      Fixing undefined method `owners' for
      ActiveRecord::Associations::Preloader::NullPreloader:Class
      
      * Use Ruby 1.9 hash format
      
      Use Ruby 1.9 hash format
      
      #24192
      
      [Rafael Mendonça França + Ladislav Smola]
      cb4f6875
  27. 03 3月, 2016 1 次提交
  28. 02 3月, 2016 1 次提交