1. 09 3月, 2018 1 次提交
  2. 26 2月, 2018 1 次提交
  3. 13 2月, 2018 1 次提交
  4. 10 2月, 2018 1 次提交
  5. 25 1月, 2018 1 次提交
    • R
      Fix `count(:all)` with eager loading and having an order other than the driving table · ebc09ed9
      Ryuta Kamizono 提交于
      This is a regression caused by 6beb4de7.
      
      In PostgreSQL, ORDER BY expressions must appear in SELECT list when
      using DISTINCT.
      
      When using `count(:all)` with eager loading, Active Record enforces
      DISTINCT to count the driving table records only. 6beb4de7 was caused the
      regression because `count(:all)` with DISTINCT path no longer removes
      ORDER BY.
      
      We need to ignore ORDER BY when DISTINCT is enforced, otherwise not
      always generated valid SQL for PostgreSQL.
      
      Fixes #31783.
      ebc09ed9
  6. 07 1月, 2018 1 次提交
  7. 20 12月, 2017 1 次提交
    • R
      Fix `count(:all)` to correctly work `distinct` with custom SELECT list · c6cd9a59
      Ryuta Kamizono 提交于
      Currently `count(:all)` with `distinct` doesn't work correctly because
      SELECT list is always replaced to `*` or primary key in that case even
      if having custom SELECT list.
      
      And also, PostgreSQL has a limitation that ORDER BY expressions must
      appear in select list for SELECT DISTINCT.
      
      Therefore, we should not replace custom SELECT list when using
      `count(:all)` with `distinct`.
      
      Closes #31277.
      c6cd9a59
  8. 09 11月, 2017 2 次提交
  9. 14 10月, 2017 1 次提交
  10. 01 9月, 2017 1 次提交
  11. 22 7月, 2017 2 次提交
  12. 20 7月, 2017 1 次提交
  13. 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
  14. 02 7月, 2017 1 次提交
  15. 01 7月, 2017 1 次提交
  16. 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
  17. 29 5月, 2017 1 次提交
  18. 01 3月, 2017 1 次提交
  19. 28 2月, 2017 1 次提交
  20. 27 2月, 2017 1 次提交
  21. 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
  22. 07 2月, 2017 2 次提交
  23. 05 1月, 2017 1 次提交
  24. 30 12月, 2016 1 次提交
  25. 29 10月, 2016 1 次提交
  26. 27 9月, 2016 1 次提交
  27. 17 9月, 2016 1 次提交
  28. 16 8月, 2016 1 次提交
  29. 07 8月, 2016 2 次提交
  30. 12 7月, 2016 1 次提交
  31. 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
  32. 20 3月, 2016 1 次提交
  33. 23 2月, 2016 1 次提交
  34. 21 12月, 2015 1 次提交