1. 04 4月, 2019 1 次提交
  2. 26 2月, 2019 1 次提交
  3. 13 2月, 2019 1 次提交
    • R
      Fix `pluck` and `select` with custom attributes · 0ee96d13
      Ryuta Kamizono 提交于
      Currently custom attributes are always qualified by the table name in
      the generated SQL wrongly even if the table doesn't have the named
      column, it would cause an invalid SQL error.
      
      Custom attributes should only be qualified if the table has the same
      named column.
      0ee96d13
  4. 18 1月, 2019 2 次提交
  5. 04 1月, 2019 1 次提交
    • A
      Make average compatible accross Ruby versions · d237c7c7
      Alberto Almagro 提交于
      Since Ruby 2.6.0 NilClass#to_d is returning `BigDecimal` 0.0, this
      breaks `average` compatibility with prior Ruby versions. This patch
      makes `average` return `nil` in all Ruby versions when there are no
      rows.
      d237c7c7
  6. 02 1月, 2019 1 次提交
  7. 27 8月, 2018 1 次提交
  8. 25 8月, 2018 1 次提交
  9. 29 7月, 2018 2 次提交
  10. 26 2月, 2018 1 次提交
  11. 10 2月, 2018 2 次提交
  12. 29 1月, 2018 1 次提交
    • D
      Avoid extra calls to to_s · 2e8c8d60
      Daniel Colson 提交于
      With #31615 `type_for_attribute` accepts either
      a symbol as well as a string. `has_attribute?` and `attribute_alias`
      also accept either. Since these methods call `to_s` on the argument,
      we no longer need to do that at the call site.
      2e8c8d60
  13. 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
  14. 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
  15. 09 11月, 2017 4 次提交
  16. 06 11月, 2017 1 次提交
  17. 14 10月, 2017 1 次提交
  18. 09 10月, 2017 1 次提交
  19. 23 9月, 2017 1 次提交
  20. 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
  21. 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
  22. 22 7月, 2017 2 次提交
  23. 20 7月, 2017 1 次提交
  24. 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
  25. 02 7月, 2017 1 次提交
  26. 01 7月, 2017 1 次提交
  27. 29 6月, 2017 2 次提交
  28. 29 5月, 2017 1 次提交
  29. 05 5月, 2017 1 次提交
  30. 10 3月, 2017 1 次提交
  31. 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
      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