1. 24 12月, 2016 1 次提交
  2. 06 12月, 2016 1 次提交
  3. 24 11月, 2016 1 次提交
    • 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
  4. 09 11月, 2016 1 次提交
    • R
      Should except `:distinct` rather than `:order` for `exists?` · 2bf7c300
      Ryuta Kamizono 提交于
      Records fetching order is very important for performance if `limit` is
      presented. Should not except the order in the case.
      
      And `exists?` replaces select list to `1 AS one` therefore `:distinct`
      is useless (`DISTINCT 1 AS one`). And PostgreSQL raises the following
      error if `:distinct` and `:order` are used in the same time.
      
      ```
      ERROR:  for SELECT DISTINCT, ORDER BY expressions must appear in select list
      ```
      2bf7c300
  5. 23 9月, 2016 1 次提交
  6. 03 9月, 2016 1 次提交
  7. 18 8月, 2016 1 次提交
  8. 16 8月, 2016 2 次提交
  9. 15 8月, 2016 1 次提交
  10. 14 8月, 2016 1 次提交
  11. 08 8月, 2016 1 次提交
  12. 07 8月, 2016 2 次提交
  13. 28 7月, 2016 1 次提交
  14. 16 6月, 2016 1 次提交
    • R
      Prevent `RangeError` for `FinderMethods#exists?` · 1cf467b7
      Ryuta Kamizono 提交于
      `FinderMethods#exists?` should return a boolean rather than raising an
      exception.
      
      `UniquenessValidator#build_relation` catches a `RangeError` because it
      includes type casting due to a string value truncation. But a string
      value truncation was removed at #23523 then type casting in
      `build_relation` is no longer necessary. aa062318 removes type casting in
      `build_relation` then a `RangeError` moves to `relation.exists?`.
      
      This change will remove the catching a `RangeError`.
      1cf467b7
  15. 13 6月, 2016 1 次提交
  16. 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
  17. 12 4月, 2016 1 次提交
  18. 14 3月, 2016 1 次提交
  19. 28 2月, 2016 3 次提交
  20. 21 2月, 2016 1 次提交
  21. 14 2月, 2016 1 次提交
  22. 13 2月, 2016 2 次提交
  23. 11 2月, 2016 2 次提交
    • Y
      remove warnings from FinderMethods · 424b2019
      yuuji.yaginuma 提交于
      This removes the following warnings.
      
      ```
      activerecord/lib/active_record/relation/finder_methods.rb:252: warning: ambiguous first argument; put parentheses or a space even after `-' operator
      activerecord/lib/active_record/relation/finder_methods.rb:258: warning: ambiguous first argument; put parentheses or a space even after `-' operator
      activerecord/lib/active_record/relation/finder_methods.rb:268: warning: ambiguous first argument; put parentheses or a space even after `-' operator
      activerecord/lib/active_record/relation/finder_methods.rb:274: warning: ambiguous first argument; put parentheses or a space even after `-' operator
      ```
      424b2019
    • B
      rename to 'second_to_last' and 'third_to_last' · e8aeda2a
      Brian Christian 提交于
      e8aeda2a
  24. 10 2月, 2016 1 次提交
  25. 04 2月, 2016 2 次提交
  26. 02 2月, 2016 1 次提交
  27. 28 1月, 2016 2 次提交
  28. 25 12月, 2015 2 次提交
    • B
      Fix `first(limit)` to take advantage of `loaded?` records if available · b42c3255
      Ben Woosley 提交于
      I realized that `first(2)`, etc. was unnecessarily querying for the
      records when they were already preloaded. This was because
      `find_nth_with_limit` can not know which `@records` to return because
      it conflates the `offset` and `index` into a single variable, while
      the `@records` only needs the `index` itself to select the proper
      record.
      
      Because `find_nth` and `find_nth_with_limit` are public methods, I
      instead introduced a private method `find_nth_with_limit_and_offset`
      which is called internally and handles the `loaded?` checking.
      
      Once the `offset` argument is removed from `find_nth`,
      `find_nth_with_limit_and_offset` can be collapsed into
      `find_nth_with_limit`, with `offset` always equal to `offset_index`.
      b42c3255
    • B
      Deprecate passing `offset` to `find_nth` · 16a476e4
      Ben Woosley 提交于
      All uses of the `offset` are passing `offset_index`. Better to push
      down the `offset` consideration into `find_nth`.
      
      This also works toward enabling `find_nth_with_limit` to take
      advantage of the `loaded?` state of the relation.
      16a476e4
  29. 18 12月, 2015 1 次提交
    • M
      Implement limit & offset for ourselves · 04309aee
      Matthew Draper 提交于
      We know the query will return exactly one row for each entry in the
      `ids` array, so we can do all the limit/offset calculations on that
      array, in advance.
      
      I also split our new ordered-ids behaviour out of the existing
      `find_some` method: especially with this change, the conditionals were
      overwhelming the actual logic.
      04309aee
  30. 15 12月, 2015 2 次提交
    • S
      Revert "Perform a more efficient query in `Relation#any?`" · 4ecabed2
      Sean Griffin 提交于
      This reverts commit 6d5b1fdf.
      
      `eager_load` and `references` can include hashes, which won't match up
      with `references`
      
      A test case has been added to demonstrate the problem
      4ecabed2
    • S
      Perform a more efficient query in `Relation#any?` · 6d5b1fdf
      Sean Griffin 提交于
      This was changed in 421c81bd, as `exists?` blows up if you are eager
      loading a polymorphic association, as it'll try to construct a join to
      that table. The previous change decided to execute a `count` instead,
      which wouldn't join.
      
      Of course, the only time we actually need to perform a join on the eager
      loaded values (which would perform a left outer join) is if they're
      being referenced in the where clause. This doesn't affect inner joins.
      6d5b1fdf