- 25 7月, 2017 1 次提交
-
-
由 Rafael França 提交于
Fix `COUNT(DISTINCT ...)` with `ORDER BY` and `LIMIT`
-
- 10 3月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
Follow up of #24203. Since b644964b `ActiveRecord::Relation` includes `Enumerable` so it is enough to call `super` simply.
-
- 26 2月, 2017 3 次提交
-
-
由 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.
-
由 Ryuta Kamizono 提交于
`select_values` is a local variable defined at previous line. `select_values += select_values` is totally useless.
-
由 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
-
- 07 2月, 2017 2 次提交
-
-
由 Ryuta Kamizono 提交于
This reverts commit 28977f1f.
-
由 Ryuta Kamizono 提交于
If select clause is specified and last column has a column alias, additional column alias causes a statement invalid. Add test coverage for counting a single column with NULL values. Fixes #27676, #27682, and #27705.
-
- 05 1月, 2017 1 次提交
-
-
由 Akira Matsuda 提交于
Actually, private methods cannot be called with `self.`, so it's not just redundant, it's a bad habit in Ruby
-
- 06 11月, 2016 1 次提交
-
-
由 Ryuta Kamizono 提交于
If `limit_value` is presented, records fetching order is very important for performance. Should not unscope the order in the case.
-
- 04 10月, 2016 1 次提交
-
-
由 Keenan Brock 提交于
-
- 14 9月, 2016 1 次提交
-
-
由 Ryuta Kamizono 提交于
All indentation was normalized by rubocop auto-correct at 80e66cc4. But comments was still kept absolute position. This commit aligns comments with method definitions for consistency.
-
- 11 9月, 2016 1 次提交
-
-
由 Ryuta Kamizono 提交于
`column_for` was changed to `type_for` to return `type` object at 36bd52b4. But variable name is still `column`. It is very confusing. Rename variable name `column` to `type` for readability.
-
- 26 8月, 2016 1 次提交
-
-
由 Ryuta Kamizono 提交于
For reduce instantiating `Type::Value`.
-
- 16 8月, 2016 1 次提交
-
-
由 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}.
-
- 07 8月, 2016 3 次提交
-
-
由 Xavier Noria 提交于
-
由 Xavier Noria 提交于
-
由 Xavier Noria 提交于
The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
-
- 04 8月, 2016 1 次提交
-
-
由 Ryuta Kamizono 提交于
-
- 11 7月, 2016 1 次提交
-
-
由 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
-
- 19 5月, 2016 1 次提交
-
-
由 Jeremy Daer 提交于
Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005 * Forward compat with new unified Integer class in Ruby 2.4+. * Backward compat with separate Fixnum/Bignum in Ruby 2.2 & 2.3. * Drops needless Fixnum distinction in docs, preferring Integer.
-
- 20 3月, 2016 1 次提交
-
-
由 Erik Michaels-Ober 提交于
-
- 04 2月, 2016 2 次提交
-
-
由 Matthew Draper 提交于
-
由 Matthew Draper 提交于
This still isn't as separated as I'd like, but it at least moves most of the burden of alias mapping in one place.
-
- 22 10月, 2015 2 次提交
-
-
由 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
-
由 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" ```
-
- 21 10月, 2015 1 次提交
-
-
由 Soutaro Matsumoto 提交于
Column names inserted via `group` have to be qualified with table name.
-
- 14 10月, 2015 1 次提交
-
-
由 Yves Senn 提交于
The focus of this change is to make the API more accessible. References to method and classes should be linked to make it easy to navigate around. This patch makes exzessiv use of `rdoc-ref:` to provide more readable docs. This makes it possible to document `ActiveRecord::Base#save` even though the method is within a separate module `ActiveRecord::Persistence`. The goal here is to bring the API closer to the actual code that you would write. This commit only deals with Active Record. The other gems will be updated accordingly but in different commits. The pass through Active Record is not completely finished yet. A follow up commit will change the spots I haven't yet had the time to update. /cc @fxn
-
- 13 10月, 2015 1 次提交
-
-
由 Yves Senn 提交于
-
- 26 9月, 2015 1 次提交
-
-
由 amitkumarsuroliya 提交于
-
- 23 9月, 2015 2 次提交
-
-
由 yuuji.yaginuma 提交于
This removes the following warning. ``` activerecord/lib/active_record/relation/calculations.rb:74: warning: `&' interpreted as argument prefix ```
-
由 yui-knk 提交于
Arguments of `#sum` does not match with other shortcuts methods (count, average, minimum, and maximum). This commit fix these two points: * call `super` with only block arguments First argument of `super` method, `Enumerable#sum`, is `identity` and first argument of `AR::Calculations#sum` is `column_name`. `Enumerable#sum` does not expect `column_name` to be passed. * Change first argument of `sum` from array arguemnt to single argument to match other shortcuts methods. When `sum` accept array arguemnt, user can pass multi arguments and an exception is raised from `calculate`.
-
- 03 7月, 2015 1 次提交
-
-
由 Jon Atack 提交于
as #uniq will be removed from Rails 5.0 as per the Active Support exception raised: ActiveSupport::DeprecationException: DEPRECATION WARNING: uniq is deprecated and will be removed from Rails 5.0 (use distinct instead).
-
- 01 7月, 2015 1 次提交
-
-
由 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])`.
-
- 27 6月, 2015 1 次提交
-
-
由 Prem Sichanugrist 提交于
This is to show users that they can chain `.uniq` and `.pluck` to get the `DISTINCT column` result. They don't have to do `DISTINCT column` themselves.
-
- 20 6月, 2015 2 次提交
-
-
由 Sean Griffin 提交于
After discussing, we've decided it makes more sense to include it. We're already forwarding every conflicting method to `to_a`, and there's no conflation of concerns. `Enumerable` has no mutating methods, and it just allows us to simplify the code. No existing methods will have a change in behavior. Un-overridden Enumerable methods will simply delegate to `each`. [Sean Griffin & bogdan]
-
由 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.
-
- 29 5月, 2015 1 次提交
-
-
由 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.
-
- 13 4月, 2015 1 次提交
-
-
由 wingfire 提交于
Documentation is giving an example that can be replaced by a more dry command. Give a hint that ids can be used instead of pluck(:id).
-
- 17 3月, 2015 1 次提交
-
-
由 Ben Woosley 提交于
It is redundant with tests in `eager_loading?`, but for the difference between `includes_values.present?` and `includes_values.any?`, which is a difference without a distinction because `false` has no meaning for `includes`.
-
- 28 2月, 2015 1 次提交
-
-
由 Akira Matsuda 提交于
[ci skip]
-