1. 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
  2. 08 8月, 2015 1 次提交
  3. 20 6月, 2015 1 次提交
  4. 06 6月, 2015 1 次提交
  5. 04 6月, 2015 2 次提交
  6. 30 5月, 2015 1 次提交
  7. 23 3月, 2015 1 次提交
  8. 05 1月, 2015 1 次提交
  9. 23 12月, 2014 1 次提交
  10. 05 12月, 2014 1 次提交
  11. 04 12月, 2014 1 次提交
  12. 03 12月, 2014 1 次提交
    • M
      Refactor `build_from_hash` to convert dot notation to hash first · fcc3cbc7
      Melanie Gilman 提交于
      This ensures that we're handling all forms of nested tables the same way.
      
      We're aware that the `convert_dot_notation_to_hash` method will cause a
      performance hit, and we intend to come back to it once we've refactored some of
      the surrounding code.
      
      [Melissa Xie & Melanie Gilman]
      fcc3cbc7
  13. 29 11月, 2014 1 次提交
  14. 14 11月, 2014 1 次提交
  15. 03 11月, 2014 1 次提交
  16. 01 11月, 2014 1 次提交
    • S
      Treat strings greater than int max value as out of range · e62fff40
      Sean Griffin 提交于
      Sufficiently large integers cause `find` and `find_by` to raise
      `StatementInvalid` instead of `RecordNotFound` or just returning `nil`.
      Given that we can't cast to `nil` for `Integer` like we would with junk
      data for other types, we raise a `RangeError` instead, and rescue in
      places where it would be highly unexpected to get an exception from
      casting.
      
      Fixes #17380
      e62fff40
  17. 20 9月, 2014 1 次提交
    • G
      Fix find_by with associations not working with adequate record · 90f99689
      Godfrey Chan 提交于
      For now, we will just skip the cache when a non-column key is used in the hash.
      If the future, we can probably move some of the logic in PredicateBuilder.expand
      up the chain to make caching possible for association queries.
      
      Closes #16903
      Fixes #16884
      90f99689
  18. 07 9月, 2014 1 次提交
    • C
      Fix query with nested array in Active Record · 72d1663b
      Cristian Bica 提交于
      `User.where(id: [[1,2],3])` was equal to `User.where(id:[1, 2, 3])`
      in Rails 4.1.x but because of some refactoring in Arel this stopped
      working in 4.2.0. This fixes it in Rails.
      
      [Dan Olson & Cristian Bica]
      72d1663b
  19. 26 8月, 2014 2 次提交
    • G
      Override #find_by! in core to enable AST caching · 37939e28
      Godfrey Chan 提交于
      37939e28
    • G
      Fixed find_by("sql fragment without bindings") on master · 58c5261e
      Godfrey Chan 提交于
      * Also duplicated find_by tests from relations_test.rb to finder_test.rb now
      	that we have a completely different implementation on the class (in core.rb
      	with AST caching stuff).
      
      * Also removed a (failing) test that used mocks. Now that we have tests for the
        behavior, there's no point having another test that tests the implementation
      	(that it delegates). Further, what the test was implying is nolonger true with
      	the current implementation, because Class.find_by is a real method now.
      58c5261e
  20. 19 8月, 2014 1 次提交
  21. 14 8月, 2014 1 次提交
  22. 26 6月, 2014 1 次提交
    • S
      Deprecate automatic counter caches on has_many :through · d730e374
      Sean Griffin 提交于
      Reliant on https://github.com/rails/rails/pull/15747 but pulled to a
      separate PR to reduce noise. `has_many :through` associations have the
      undocumented behavior of automatically detecting counter caches.
      However, the way in which it does so is inconsistent with counter caches
      everywhere else, and doesn't actually work consistently.
      
      As with normal `has_many` associations, the user should specify the
      counter cache on the `belongs_to`, if they'd like it updated.
      d730e374
  23. 18 6月, 2014 1 次提交
  24. 10 6月, 2014 2 次提交
  25. 14 3月, 2014 3 次提交
  26. 10 3月, 2014 3 次提交
  27. 04 3月, 2014 1 次提交
    • M
      Make exists? use bound values. · f317cc8b
      Martin Schürrer 提交于
      When we build a query with an inline value that is a numeric (e.g.
      because it's out of range for an int4) PostgreSQL doesn't use an index
      on the column, since it's now comparing numerics and not int4s.
      
      This leads to a _very_ slow query.
      
      When we use bound parameters instead of inline values PostgreSQL
      raises numeric_value_out_of_range since no automatic coercion happens.
      f317cc8b
  28. 25 1月, 2014 1 次提交
  29. 22 1月, 2014 1 次提交
    • J
      Ensure AR #second, #third, etc. finders work through associations · 03855e79
      Jason Meller 提交于
      This commit fixes two regressions introduced in cafe31a0 where
      newly created finder methods #second, #third, #forth, and #fifth
      caused a NoMethodError error on reload associations and where we
      were pulling the wrong element out of cached associations.
      
      Examples:
      
        some_book.authors.reload.second
      
        # Before
        # => NoMethodError: undefined method 'first' for nil:NilClass
      
        # After
        # => #<Author id: 2, name: "Sally Second", ...>
      
        some_book.first.authors.first
        some_book.first.authors.second
      
        # Before
        # => #<Author id: 1, name: "Freddy First", ...>
        # => #<Author id: 1, name: "Freddy First", ...>
      
        # After
        # => #<Author id: 1, name: "Freddy First", ...>
        # => #<Author id: 2, name: "Sally Second", ...>
      
      Fixes #13783.
      03855e79
  30. 21 1月, 2014 1 次提交
    • J
      Ensure #second acts like #first AR finder · cafe31a0
      Jason Meller 提交于
      This commit bring the famous ordinal Array instance methods defined
      in ActiveSupport into ActiveRecord as fully-fledged finders.
      
      These finders ensure a default ascending order of the table's primary
      key, and utilize the OFFSET SQL verb to locate the user's desired
      record. If an offset is defined in the query, calling #second adds
      to the offset to get the actual desired record.
      
      Fixes #13743.
      cafe31a0
  31. 16 1月, 2014 1 次提交
  32. 13 12月, 2013 1 次提交
  33. 11 12月, 2013 1 次提交
    • L
      Prevent invalid code when using dynamic finders with Ruby's reserved words. · 23ce3e5f
      Lauro Caetano 提交于
      The dynamic finder was creating the method signature with the parameters name,
      which may have reserved words and this way creating invalid Ruby code.
      
      Closes: #13261
      
          Example:
      
              # Before
              Dog.find_by_alias('dog name')
      
              # Was creating this method
              def self.find_by_alias(alias, options = {})
      
              # After
              Dog.find_by_alias('dog name')
      
              # Will create this method
              def self.find_by_alias(_alias, options = {})
      23ce3e5f