1. 16 8月, 2016 2 次提交
  2. 11 8月, 2016 1 次提交
  3. 07 8月, 2016 4 次提交
  4. 17 7月, 2016 1 次提交
  5. 11 4月, 2016 1 次提交
  6. 17 2月, 2016 2 次提交
    • P
      Show proper error message when a non-relation object is passed to AR::Relation#or · e254665a
      Prathamesh Sonpatki 提交于
      - Previously it used to show error message
          <"undefined method `limit_value' for {:title=>\"Rails\"}:Hash">
      
      - Now it shows following error message.
      
          >> Post.where.not(name: 'DHH').or(name: 'Tenderlove')
          ArgumentError: You have passed Hash object to #or. Pass an ActiveRecord::Relation object instead.
      
      - Fixes #23714.
      e254665a
    • P
      Fixed `where` for polymorphic associations when passed an array containing different types. · 359adaed
      Philippe Huibonhoa 提交于
      When passing in an array of different types of objects to `where`, it would only take into account the class of the first object in the array.
      
          PriceEstimate.where(estimate_of: [Treasure.find(1), Car.find(2)])
      	# => SELECT "price_estimates".* FROM "price_estimates"
               WHERE ("price_estimates"."estimate_of_type" = 'Treasure' AND "price_estimates"."estimate_of_id" IN (1, 2))
      
      This is fixed to properly look for any records matching both type and id:
      
          PriceEstimate.where(estimate_of: [Treasure.find(1), Car.find(2)])
          # => SELECT "price_estimates".* FROM "price_estimates"
               WHERE (("price_estimates"."estimate_of_type" = 'Treasure' AND "price_estimates"."estimate_of_id" = 1)
               OR ("price_estimates"."estimate_of_type" = 'Car' AND "price_estimates"."estimate_of_id" = 2))
      359adaed
  7. 04 2月, 2016 2 次提交
  8. 15 1月, 2016 1 次提交
  9. 13 1月, 2016 3 次提交
    • R
      Improve error message for #or when it is structurally incompatible · f466cd7f
      Rafael Mendonça França 提交于
      When you are using scopes and you chaining these scopes it is hard to
      know which are the values that are incompatible. This way you can read
      the message and know for which values you need to look for.
      
      [Herminio Torres]
      f466cd7f
    • S
      Revert "Change `WhereClause#merge` to same named columns on diff tables" · b64b7545
      Sean Griffin 提交于
      This reverts commit 5d41cb3b.
      
      This implementation does not properly handle cases involving predicates
      which are not associated with a bind param. I have the fix in mind, but
      don't have time to implement just yet. It will be more similar to #22823
      than not.
      b64b7545
    • S
      Change `WhereClause#merge` to same named columns on diff tables · 5d41cb3b
      Sean Griffin 提交于
      While the predicates are an arel equality node where the left side is a
      full arel attribute, the binds just have the name of the column and
      nothing else. This means that while splitting the predicates can include
      the table as a factor, the binds cannot. It's entirely possible that we
      might be able to have the bind params carry a bit more information (I
      don't believe the name is used for anything but logging), and that is
      probably a worthwhile change to make in the future.
      
      However the simplest (and likely slightly faster) solution is to simply
      use the indices of the conflicts in both cases. This means that we only
      have to compute the collision space once, instead of twice even though
      we're doing an additional array iteration. Regardless, this method isn't
      a performance hotspot.
      
      Close #22823.
      
      [Ben Woosley & Sean Griffin]
      5d41cb3b
  10. 02 12月, 2015 1 次提交
  11. 24 11月, 2015 1 次提交
    • S
      Remove blanket array delegation from `Relation` · 9d79334a
      Sean Griffin 提交于
      As was pointed out by #17128, our blacklist of mutation methods was
      non-exhaustive (and would need to be kept up to date with each new
      version of Ruby). Now that `Relation` includes `Enumerable`, the number
      of methods that we actually need to delegate are pretty small. As such,
      we can change to explicitly delegating the few non-mutation related
      methods that `Array` has which aren't on `Enumerable`
      9d79334a
  12. 02 11月, 2015 1 次提交
  13. 31 10月, 2015 1 次提交
  14. 17 10月, 2015 1 次提交
  15. 16 10月, 2015 1 次提交
  16. 02 10月, 2015 1 次提交
  17. 17 9月, 2015 1 次提交
  18. 28 5月, 2015 1 次提交
  19. 26 5月, 2015 2 次提交
  20. 26 3月, 2015 1 次提交
    • J
      Add `config.active_record.warn_on_records_fetched_greater_than` option · 4d6fbe29
      Jason Nochlin 提交于
      When set to an integer, a warning will be logged whenever a result set
      larger than the specified size is returned by a query. Fixes #16463
      
      The warning is outputed a module which is prepended in an initializer,
      so there will be no performance impact if
      `config.active_record.warn_on_records_fetched_greater_than` is not set.
      4d6fbe29
  21. 04 2月, 2015 1 次提交
    • S
      Respect custom primary keys for associations in `Relation#where` · cd0ed12d
      Sean Griffin 提交于
      While we query the proper columns, we go through normal handling for
      converting the value to a primitive which assumes it should use the
      table's primary key. If the association specifies a different value (and
      we know that we're working with an association), we should use the
      custom primary key instead.
      
      Fixes #18813.
      cd0ed12d
  22. 30 1月, 2015 1 次提交
  23. 29 1月, 2015 2 次提交
  24. 28 1月, 2015 4 次提交
    • 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
      Use an `Attribute` object to represent a bind value · 6c235dd9
      Sean Griffin 提交于
      The column is primarily used for type casting, which we're trying to
      separate from the idea of a column. Since what we really need is the
      combination of a name, type, and value, let's use the object that we
      already have to represent that concept, rather than this tuple. No
      consumers of the bind values have been changed, only the producers
      (outside of tests which care too much about internals). This is
      *finally* possible since the bind values are now produced from a
      reasonable number of lcoations.
      6c235dd9
    • S
      `WhereClause#predicates` does not need to be public · d26dd008
      Sean Griffin 提交于
      The only place it was accessed was in tests. Many of them have another
      way that they can test their behavior, that doesn't involve reaching
      into internals as far as they did. `AssociationScopeTest` is testing a
      situation where the where clause would have one bind param per
      predicate, so it can just ignore the predicates entirely. The where
      chain test was primarly duplicating the logic tested on `WhereClause`
      directly, so I instead just make sure it calls the appropriate method
      which is fully tested in isolation.
      d26dd008
    • S
      Move where grouping into `WhereClause` · a5fcdae0
      Sean Griffin 提交于
      a5fcdae0
  25. 27 1月, 2015 2 次提交
    • S
      Move the `from` bind logic to a `FromClause` class · bdc51416
      Sean Griffin 提交于
      Contrary to my previous commit message, it wasn't overkill, and led to
      much cleaner code.
      
      [Sean Griffin & anthonynavarre]
      bdc51416
    • S
      Remove `Relation#bind_values=` · 8436e2c2
      Sean Griffin 提交于
      The last place that was assigning it was when `from` is called with a
      relation to use as a subquery. The implementation was actually
      completely broken, and would break if you called `from` more than once,
      or if you called it on a relation, which also had its own join clause,
      as the bind values would get completely scrambled. The simplest solution
      was to just move it into its own array, since creating a `FromClause`
      class for this would be overkill.
      8436e2c2
  26. 26 1月, 2015 1 次提交