1. 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
  2. 28 5月, 2016 1 次提交
  3. 27 5月, 2016 1 次提交
  4. 19 5月, 2016 1 次提交
  5. 07 5月, 2016 1 次提交
    • S
      Allow the connection adapters to determine the order of bind params · 96f3f3d8
      Sean Griffin 提交于
      In 5.0 we use bind parameters for limit and offset, while in 4.2 we used
      the values directly. The code as it was written assumed that limit and
      offset worked as `LIMIT ? OFFSET ?`. Both Oracle and SQL Server have a
      different syntax, where the offset is stated before the limit. We
      delegate this behavior to the connection adapter so that these adapters
      are able to determine how the bind parameters are flattened based on
      what order their specification has the various clauses appear.
      
      Fixes #24775
      96f3f3d8
  6. 06 5月, 2016 1 次提交
  7. 05 5月, 2016 1 次提交
  8. 19 4月, 2016 1 次提交
  9. 13 4月, 2016 1 次提交
    • S
      Allow symbols using "dot notation" to be passed to where · 714ab8cb
      Sean Griffin 提交于
      In 04ac5655 I assumed that we would
      never want to pass the "table_name.column_name" form to where with a
      symbol. However, in Ruby 2.2 and later, you can quote symbols using the
      new hash syntax, so it's a semi-reasonable thing to do if we want to
      support the dot notation (which I'd rather deprecate, but that would be
      too painful of a migration).
      
      Instead we've changed the definition of "this is a table name with a
      dot" to when the value associated is a hash. It would make very little
      sense to write `where("table_name.column_name": { foo: :bar })` in any
      scenario (other than equality for a JSON column which we don't support
      through `where` in this way).
      
      Close #24514.
      714ab8cb
  10. 12 4月, 2016 1 次提交
  11. 01 4月, 2016 1 次提交
    • S
      Ensure associations still work when the table name contains a dot · 04ac5655
      Sean Griffin 提交于
      This issue occured because associations now call `where` directly, and a
      dot in the key name for `where` means nested tables. For this fix, we
      now pass the table name as a symbol, and do not attempt to expand
      symbols containing a dot.
      
      This is a temporary fix. I do not think we should support table names
      containing a dot, as it has a special meaning in most backends, as well
      as most APIs that involve table names. This commit does not include a
      test, as I am going to deprecate table names containing dots in the
      following commit.
      
      Fixes #24367
      04ac5655
  12. 31 3月, 2016 1 次提交
  13. 20 3月, 2016 1 次提交
  14. 14 3月, 2016 1 次提交
  15. 28 2月, 2016 3 次提交
  16. 21 2月, 2016 1 次提交
  17. 20 2月, 2016 1 次提交
    • K
      Add methods to array delegation from `Relation` · 95c24e9f
      Kevin Dougherty 提交于
      Delegation of some `Array` methods was removed in commit 9d79334a. That
      change did add explicit delegation of a few methods that `Array` has but
      which aren't on `Enumerable`.  However, a few non-mutation methods were
      omitted.  This adds `Array` delegation of `#in_groups`, `#in_groups_of`,
      `#shuffle` and `#split`.  This allows things like
      `MyThing.all.in_groups_of(3) { ... }` to continue working as they did
      before commit 9d79334a.
      95c24e9f
  18. 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
  19. 14 2月, 2016 1 次提交
  20. 13 2月, 2016 2 次提交
  21. 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
  22. 10 2月, 2016 1 次提交
  23. 04 2月, 2016 2 次提交
  24. 03 2月, 2016 1 次提交
    • S
      Add initial support for allowing an error on order or limit of queries being ignored in batches · 08a74811
      Scott Ringwelski 提交于
      add some documentation and add 4 tests regarding error vs. warning behavior
      
      fix a typo when referring to the message
      
      go back to default in tests so that ordering is not important. use a constant instead of method. fix assert_nothing_raised call. use self.klass to allow per class configuration
      
      remove logger warn assets as that is tested elsewhere. pass error_on_ignore through find_each and find_in_batches also.
      
      add blocks to the finds so that the code is actually executed
      
      put the setting back to default in an ensure
      
      Add a changelog entry
      08a74811
  25. 02 2月, 2016 1 次提交
  26. 28 1月, 2016 2 次提交
  27. 27 1月, 2016 1 次提交
  28. 22 1月, 2016 1 次提交
    • S
      Use bind parameters for ranges in where clauses · 6efb3945
      Sean Griffin 提交于
      This is a similar case to wanting ot use bind params for limit and
      offset. Right now passing a range grows the amount of prepared
      statements in an unbounded fashion. We could avoid using prepared
      statements in that case, similar to what we do with arrays, but there's
      a known number of variants for ranges.
      
      This ends up duplicating some of the logic from Arel for how to handle
      potentially infinite ranges, and that behavior may be removed from Arel
      in the future.
      
      Fixes #23074
      6efb3945
  29. 18 1月, 2016 1 次提交
  30. 15 1月, 2016 1 次提交
  31. 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