1. 09 11月, 2017 1 次提交
  2. 06 11月, 2017 1 次提交
  3. 14 10月, 2017 1 次提交
  4. 09 10月, 2017 1 次提交
  5. 23 9月, 2017 1 次提交
  6. 15 8月, 2017 1 次提交
    • A
      Ensure sum honors distinct on has_many through · 566f1fd0
      Aaron Wortham 提交于
      When using a has_many through relation and then summing an attribute
      the distinct was not being used. This will ensure that when summing
      an attribute, the number is only used once when distinct has been used.
      566f1fd0
  7. 24 7月, 2017 1 次提交
    • S
      Refactor Active Record to let Arel manage bind params · 213796fb
      Sean Griffin 提交于
      A common source of bugs and code bloat within Active Record has been the
      need for us to maintain the list of bind values separately from the AST
      they're associated with. This makes any sort of AST manipulation
      incredibly difficult, as any time we want to potentially insert or
      remove an AST node, we need to traverse the entire tree to find where
      the associated bind parameters are.
      
      With this change, the bind parameters now live on the AST directly.
      Active Record does not need to know or care about them until the final
      AST traversal for SQL construction. Rather than returning just the SQL,
      the Arel collector will now return both the SQL and the bind parameters.
      At this point the connection adapter will have all the values that it
      had before.
      
      A bit of this code is janky and something I'd like to refactor later. In
      particular, I don't like how we're handling associations in the
      predicate builder, the special casing of `StatementCache::Substitute` in
      `QueryAttribute`, or generally how we're handling bind value replacement
      in the statement cache when prepared statements are disabled.
      
      This also mostly reverts #26378, as it moved all the code into a
      location that I wanted to delete.
      
      /cc @metaskills @yahonda, this change will affect the adapters
      
      Fixes #29766.
      Fixes #29804.
      Fixes #26541.
      Close #28539.
      Close #24769.
      Close #26468.
      Close #26202.
      
      There are probably other issues/PRs that can be closed because of this
      commit, but that's all I could find on the first few pages.
      213796fb
  8. 22 7月, 2017 2 次提交
  9. 20 7月, 2017 1 次提交
  10. 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
  11. 02 7月, 2017 1 次提交
  12. 01 7月, 2017 1 次提交
  13. 29 6月, 2017 2 次提交
  14. 29 5月, 2017 1 次提交
  15. 05 5月, 2017 1 次提交
  16. 10 3月, 2017 1 次提交
  17. 26 2月, 2017 3 次提交
    • 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
      Remove useless `select_values += select_values` · 97d46c17
      Ryuta Kamizono 提交于
      `select_values` is a local variable defined at previous line.
      `select_values += select_values` is totally useless.
      97d46c17
    • 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
  18. 07 2月, 2017 2 次提交
  19. 05 1月, 2017 1 次提交
  20. 06 11月, 2016 1 次提交
  21. 04 10月, 2016 1 次提交
  22. 14 9月, 2016 1 次提交
  23. 11 9月, 2016 1 次提交
  24. 26 8月, 2016 1 次提交
  25. 16 8月, 2016 1 次提交
    • M
      Fix count which would sometimes force a DISTINCT · 0aae7806
      Maxime Lapointe 提交于
      The current behaviour of checking if there is a LEFT OUTER JOIN arel
      node to detect if we are doing eager_loading is wrong. This problem
      wasn't frequent before as only some pretty specific cases would add
      a LEFT OUTER JOIN arel node. However, the recent new feature
      left_outer_joins also add this node and made this problem happen
      frequently.
      
      Since in the perform_calculation function, we don't have access to
      eager_loading information, I had to extract the logic for the distinct
      out to the calculate method.
      
      As I was in the file for left_outer_join tests, I fixed a few that had
      bugs and I replaced some that were really weak with something that
      will catch more issues.
      
      In relation tests, the first test I changed would have failed if it
      had validated the hash returned by count instead of just checking how
      many pairs were in it. This is because this merge of join currently
      transforms the join node into an outer join node, which then made
      count do a distinct. So before this change, the return was
      {1=>1, 4=>1, 5=>1}.
      0aae7806
  26. 07 8月, 2016 3 次提交
  27. 04 8月, 2016 1 次提交
  28. 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
  29. 19 5月, 2016 1 次提交
  30. 20 3月, 2016 1 次提交
  31. 04 2月, 2016 2 次提交
  32. 22 10月, 2015 1 次提交
    • R
      Refactor Calculations#execute_grouped_calculation and clean AR test case · 4f21d42f
      Rafael Sales 提交于
      * When tried to use `Company#accounts` test/models/company.rb I got:
      
      ```
      ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column:
      accounts.company_id: SELECT COUNT(*) AS count_all, "companies"."firm_id"
      AS companies_firm_id FROM "companies" INNER JOIN "accounts" ON
      "accounts"."company_id" = "companies"."id" GROUP BY "companies"."firm_id"
      ```
      
      * The refactor on Calculations class was just to simplify the code
      4f21d42f