1. 10 2月, 2016 1 次提交
  2. 04 2月, 2016 2 次提交
  3. 02 2月, 2016 1 次提交
  4. 28 1月, 2016 2 次提交
  5. 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
  6. 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
  7. 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
  8. 14 10月, 2015 1 次提交
    • Y
      applies new doc guidelines to Active Record. · 428d47ad
      Yves Senn 提交于
      The focus of this change is to make the API more accessible.
      References to method and classes should be linked to make it easy to
      navigate around.
      
      This patch makes exzessiv use of `rdoc-ref:` to provide more readable
      docs. This makes it possible to document `ActiveRecord::Base#save` even
      though the method is within a separate module
      `ActiveRecord::Persistence`. The goal here is to bring the API closer to
      the actual code that you would write.
      
      This commit only deals with Active Record. The other gems will be
      updated accordingly but in different commits. The pass through Active
      Record is not completely finished yet. A follow up commit will change
      the spots I haven't yet had the time to update.
      
      /cc @fxn
      428d47ad
  9. 21 7月, 2015 1 次提交
    • S
      Extra caller details added to ActiveRecord::RecordNotFound · d763956e
      Sameer Rahmani 提交于
      ActiveRecord::RecordNotFound modified to store model name, primary_key
      and id of the caller model. It allows the catcher of this exception to make
      a better decision to what to do with it. For example consider this simple
      example:
      
          class SomeAbstractController < ActionController::Base
            rescue_from ActiveRecord::RecordNotFound, with: :redirect_to_404
      
            private def redirect_to_404(e)
              return redirect_to(posts_url) if e.model == 'Post'
              raise
            end
          end
      d763956e
  10. 20 6月, 2015 3 次提交
  11. 06 6月, 2015 1 次提交
  12. 04 6月, 2015 1 次提交
  13. 30 5月, 2015 1 次提交
  14. 12 5月, 2015 1 次提交
  15. 11 5月, 2015 1 次提交
  16. 11 4月, 2015 1 次提交
    • K
      Raise ArgumentError when find_by receives no arguments · 28375dd6
      Kohei Suzuki 提交于
      It fixes the strange error saying undefined method `take'.
      
      ```
      RelationTest#test_find_by_without_arg_behaves_same_with_find_by({}):
      NoMethodError: undefined method `take' for #<ActiveRecord::QueryMethods::WhereChain:0x007f9c55db1d68>
      ```
      28375dd6
  17. 31 3月, 2015 1 次提交
  18. 22 3月, 2015 1 次提交
    • P
      Fix referencing wrong aliases while joining tables of has many through · ba057a5e
      pinglamb 提交于
      association
      
      While joining table of has_many :through association, ActiveRecord will
      use the actual table name instead of through-join alias. It results with
      a wrong SQL and exception is raised. This only happens when calculation
      methods like #count is called.
      
      This issue is affecting Rails 4.1.x and 4.2.x as well.
      ba057a5e
  19. 28 2月, 2015 1 次提交
  20. 28 1月, 2015 2 次提交
    • S
      Remove Relation#bind_params · b06f64c3
      Sean Griffin 提交于
      `bound_attributes` is now used universally across the board, removing
      the need for the conversion layer. These changes are mostly mechanical,
      with the exception of the log subscriber. Additional, we had to
      implement `hash` on the attribute objects, so they could be used as a
      key for query caching.
      b06f64c3
    • S
      Unify access to bind values on Relation · 16ce2eec
      Sean Griffin 提交于
      The bind values can come from four places. `having`, `where`, `joins`,
      and `from` when selecting from a subquery that contains binds. These
      need to be kept in a specific order, since the clauses will always
      appear in that order. Up until recently, they were not.
      
      Additionally, `joins` actually did keep its bind values in a separate
      location (presumably because it's the only case that people noticed was
      broken). However, this meant that anything accessing just `bind_values`
      was broken (which most places were). This is no longer possible, there
      is only a single way to access the bind values, and it includes joins in
      the proper location. The setter was removed yesterday, so breaking `+=`
      cases is not possible.
      
      I'm still not happy that `joins` is putting it's bind values on the
      Arel AST, and I'm planning on refactoring it further, but this removes a
      ton of bug cases.
      16ce2eec
  21. 24 1月, 2015 1 次提交
  22. 27 12月, 2014 1 次提交
  23. 30 11月, 2014 1 次提交
  24. 29 11月, 2014 1 次提交
  25. 03 11月, 2014 1 次提交
  26. 02 11月, 2014 1 次提交
  27. 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
  28. 29 10月, 2014 1 次提交
    • X
      let's warn with heredocs · b3bfa361
      Xavier Noria 提交于
      The current style for warning messages without newlines uses
      concatenation of string literals with manual trailing spaces
      where needed.
      
      Heredocs have better readability, and with `squish` we can still
      produce a single line.
      
      This is a similar use case to the one that motivated defining
      `strip_heredoc`, heredocs are super clean.
      b3bfa361
  29. 14 10月, 2014 1 次提交
    • C
      Remove duplicate error message "Couldn't find..." · 90a0471a
      claudiob 提交于
      This commit removes the duplication of the error message:
      
      > Couldn't find #{@klass.name} with [#{arel.where_sql}]
      
      introduced in #15791 by adding a private method `find_nth!` that
      deals with all the method like `first!` and `second!`.
      90a0471a
  30. 05 9月, 2014 1 次提交
    • G
      Fixed regression with referencing polymorphic assoc in eager-load · a8827cb9
      Godfrey Chan 提交于
      This is cased by 03118bc5 + 9b5d603c. The first commit referenced the undefined
      local variable `column` when it should be using `reflection.type` as the lookup
      key. The second commit changed `build_arel` to not modify the `bind_values` in-
      place so we need to combine the arel's `bind_values` with the relation's when
      building the SQL.
      
      Fixes #16591
      
      Related #15821 / #15892 / 7aeca506
      a8827cb9
  31. 19 8月, 2014 1 次提交
  32. 18 6月, 2014 1 次提交
  33. 10 6月, 2014 1 次提交