1. 01 9月, 2017 1 次提交
  2. 22 7月, 2017 2 次提交
  3. 20 7月, 2017 1 次提交
  4. 06 7月, 2017 1 次提交
    • E
      Skip query cache for in_batches and friends · 6658e374
      Eugene Kenny 提交于
      The `find_each`, `find_in_batches` and `in_batches` APIs usually operate
      on large numbers of records, where it's preferable not to load them all
      into memory at once.
      
      If the query cache is enabled, it will hold onto the query results until
      the end of the execution context (request/job), which means the memory
      used is still proportional to the total number of records. These queries
      are typically not repeated, so the query cache isn't desirable here.
      6658e374
  5. 02 7月, 2017 1 次提交
  6. 01 7月, 2017 1 次提交
  7. 06 6月, 2017 2 次提交
    • K
      b8dea23c
    • Y
      Load schema before assertion · c40502f9
      yuuji.yaginuma 提交于
      Without this, test fails because the load schema when pluck is executed.
      
      Steps to reproduce:
      
      ```
      bin/test -a postgresql -w --seed 61689 test/cases/*test.rb -n "/^(?:InheritanceComputeTypeTest#(?:test_inheritance_new_with_subclass_as_default)|CalculationsTest#(?:test_pluck_loaded_relation))$/"
      
      # Running:
      
      .F
      
      Failure:
      CalculationsTest#test_pluck_loaded_relation [/home/yaginuma/program/rails/master_y_yagi/rails/activerecord/test/cases/calculations_test.rb:722]:
      1 instead of 0 queries were executed.
      Queries:
      SELECT c.relname FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = ANY (current_schemas(false)) AND c.relname = 'companies' AND c.relkind IN ('r','v','m').
      Expected: 0
        Actual: 1
      
      bin/test test/cases/calculations_test.rb:7
      ```
      c40502f9
  8. 29 5月, 2017 1 次提交
  9. 01 3月, 2017 1 次提交
  10. 28 2月, 2017 1 次提交
  11. 27 2月, 2017 1 次提交
  12. 26 2月, 2017 2 次提交
    • E
      Include selects in group query with having clause · 18125683
      Eugene Kenny 提交于
      When a grouped calculation contains a having clause that references a
      selected value, we need to include that selected value in the query.
      
      Postgres doesn't support referencing a selected value in a having
      clause, but other databases do; we can skip the test on the pg adapter
      but run it for the others.
      
      This was fixed before in 9a298a16, but
      the test coverage was lost in 5a05207d.
      The fix regressed in 6311975f and was
      removed in 97d46c17.
      18125683
    • R
      Suppress `DISTINCT` clause outside aggregate function · d38e5d27
      Ryuta Kamizono 提交于
      `DISTINCT` clause is applied inside aggregate function by
      `operation_over_aggregate_column` if needed. Unneeded outside aggregate
      function.
      
      ```ruby
        # Before
        author.unique_categorized_posts.count
        # => SELECT DISTINCT COUNT(DISTINCT "posts"."id") FROM "posts" INNER JOIN "categorizations" ON "posts"."id" = "categorizations"."post_id" WHERE "categorizations"."author_id" = ?  [["author_id", 2]]
      
        # After
        author.unique_categorized_posts.count
        # => SELECT COUNT(DISTINCT "posts"."id") FROM "posts" INNER JOIN "categorizations" ON "posts"."id" = "categorizations"."post_id" WHERE "categorizations"."author_id" = ?  [["author_id", 2]]
      ```
      
      Closes #27615
      d38e5d27
  13. 07 2月, 2017 2 次提交
  14. 05 1月, 2017 1 次提交
  15. 30 12月, 2016 1 次提交
  16. 29 10月, 2016 1 次提交
  17. 27 9月, 2016 1 次提交
  18. 17 9月, 2016 1 次提交
  19. 16 8月, 2016 1 次提交
  20. 07 8月, 2016 2 次提交
  21. 12 7月, 2016 1 次提交
  22. 11 7月, 2016 1 次提交
    • S
      Always prefer class types to query types when casting `group` · a45363a2
      Sean Griffin 提交于
      When `group` is used in combination with any calculation method, the
      resulting hash uses the grouping expression as the key. Currently we're
      incorrectly always favoring the type reported by the query, instead of
      the type known by the class. This causes differing behavior depending on
      whether the adaptor actually gives proper types with the query or not.
      After this change, the behavior will be the same on all adaptors -- we
      see if we know the type from the class, fall back to the type from the
      query, and finally fall back to the identity type.
      
      Fixes #25595
      a45363a2
  23. 20 3月, 2016 1 次提交
  24. 23 2月, 2016 1 次提交
  25. 21 12月, 2015 1 次提交
  26. 17 12月, 2015 1 次提交
  27. 22 10月, 2015 1 次提交
    • R
      Fix generated projection fields in group by query · c2d33c4a
      Rafael Sales 提交于
      Closes #21922
      
      Let `Book(id, author_id)`, `Photo(id, book_id, author_id)` and `Author(id)`
      
      Running `Book.group(:author_id).joins(:photos).count` will produce:
      
      * Rails 4.2 - conflicts `author_id` in both projection and group by:
      ```sql
      SELECT COUNT(*) AS count_all, author_id AS author_id
        FROM "books" INNER JOIN "photos" ON "photos"."book_id" = "books"."id"
       GROUP BY author_id
      ```
      
      * Master (9d02a25d) - conflicts `author_id` only in projection:
      ```sql
      SELECT COUNT(*) AS count_all, author_id AS author_id
        FROM "books" INNER JOIN "photos" ON "photos"."book_id" = "books"."id"
       GROUP BY "books"."author_id"
      ```
      
      * With this fix:
      ```sql
      SELECT COUNT(*) AS count_all, "books"."author_id" AS books_author_id
        FROM "books" INNER JOIN "photos" ON "photos"."book_id" = "books"."id"
       GROUP BY "books"."author_id"
      ```
      c2d33c4a
  28. 21 10月, 2015 1 次提交
  29. 02 10月, 2015 1 次提交
  30. 01 7月, 2015 1 次提交
    • R
      Allow select with Arel and count as well as calculations with Arel · b220c9f9
      Roque Pinel 提交于
      It allows a query like `User.select(:name).count` to be written
      using Arel as `User.select(User.arel_table[:name]).count`.
      
      It exposes the calculations API to accept Arel nodes:
      `User.count(User.arel_table[:name])`, `User.sum(User.arel_table[:id])`,
      `Account.average(Account.arel_table[:credit_limit])`,
      `Account.maximum(Account.arel_table[:credit_limit])` and
      `Account.minimum(Account.arel_table[:credit_limit])`.
      b220c9f9
  31. 20 6月, 2015 1 次提交
    • S
      Use `Enumerable#sum` on `ActiveRecord::Relation` when a block is given · 7d14bd3f
      Sean Griffin 提交于
      This matches our behavior in other cases where useful enumerable methods
      might have a different definition in `Relation`. Wanting to actually
      enumerate over the records in this case is completely reasonable, and
      wanting `.sum` is reasonable for the same reason it is on `Enumerable`
      in the first place.
      7d14bd3f
  32. 02 6月, 2015 1 次提交
  33. 29 5月, 2015 1 次提交
    • K
      Allow Enumerable#pluck to take a splat. · 777fa257
      Kevin Deisz 提交于
      This allows easier integration with ActiveRecord, such that
      AR#pluck will now use Enumerable#pluck if the relation is loaded,
      without needing to hit the database.
      777fa257
  34. 26 5月, 2015 1 次提交
    • Y
      deprecate `Relation#uniq` use `Relation#distinct` instead. · adfab2dc
      Yves Senn 提交于
      See #9683 for the reasons we switched to `distinct`.
      
      Here is the discussion that triggered the actual deprecation #20198.
      
      `uniq`, `uniq!` and `uniq_value` are still around.
      They will be removed in the next minor release after Rails 5.
      adfab2dc
  35. 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