| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
| |
We moved more and more away from passing options to finder / calculation
methods. The `:distinct` option in `#count` was one of the remaining places.
Since we can now combine `Relation#distinct` with `Relation#count` the option
is no longer necessary and can be deprecated.
|
|
|
|
|
|
|
|
| |
The similarity of `Relation#uniq` to `Array#uniq` is confusing. Since our
Relation API is close to SQL terms I renamed `#uniq` to `#distinct`.
There is no deprecation. `#uniq` and `#uniq!` are aliases and will continue
to work. I also updated the documentation to promote the use of `#distinct`.
|
|
|
|
| |
closes #6865
|
| |
|
|
|
|
|
|
|
| |
To perform a sum calculation over the array of elements, use to_a.sum(&block).
Please check the discussion in f9cb645dfcb5cc89f59d2f8b58a019486c828c73
for more context.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This reverts commit f9cb645dfcb5cc89f59d2f8b58a019486c828c73.
Conflicts:
activerecord/CHANGELOG.md
Revert "Allow blocks for count with ActiveRecord::Relation. Document and test that sum allows blocks"
This reverts commit 9cc2bf69ce296b7351dc612a8366193390a305f3.
Conflicts:
activerecord/lib/active_record/relation/calculations.rb
|
|
|
|
| |
Closes #7551
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
On reflection, it seems like a bit of a weird method to have on
ActiveRecord::Base, and it shouldn't be needed most of the time anyway.
|
|
|
|
|
|
|
| |
It doesn't serve much purpose now that ActiveRecord::Base.all returns a
Relation.
The code is moved to active_record_deprecated_finders.
|
|
|
|
|
|
|
|
|
|
|
| |
Previously it returned an Array.
If you want an array, call e.g. `Post.to_a` rather than `Post.all`. This
is more explicit.
In most cases this should not break existing code, since
Relations use method_missing to delegate unknown methods to #to_a
anyway.
|
|
|
|
| |
Closes #1190
|
| |
|
|
|
|
| |
Fix build issue with postgresql.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Execute_grouped_calculation is one of those places where
ActiveRecord forgets that it has ARel underpinnings, and
assumes that the values provided to group_values are
strings. This artificially hobbles otherwise functional
code. This patch stops assuming that incoming values
respond to to_sym, stops using string interpolation for
table aliases on objects that support aliasing, and stops
unnecessarily joining group_values on the relation.
Additionally, it calls to_sql, if available, on objects
sent to column_alias_for, in order to get a more reasonable
alias string than a non-string's default to_str method.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Ensure it works with mix of symbols and strings, and with a select
clause possibly containing more than one column.
Also remove support for pluck with an array of columns, in favor of
passing the list of attributes:
Model.pluck(:a, :b)
See comments: https://github.com/rails/rails/pull/6500#issuecomment-6030292
|
| |
|
|
|
|
| |
Also use if/else block to not use short circuit return
|
|
|
|
| |
Fix #5990
|
|
|
|
| |
sum allows blocks
|
|
|
|
|
| |
an alias is provided. Without the alias, the column cannot be found
and properly typecast.
|
| |
|
| |
|
|
|
|
|
|
| |
1. ActiveRecord::Base is not ActiveRecord::Relation
2. The order of records from an SQL query is uncertain without an ORDER clause
3. Run your own tests when submitting a pull request
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
See the CHANGELOG for details.
Fixes #950.
|
|
|
|
| |
This reverts commit c99d507fccca2e9e4d12e49b4387e007c5481ae9.
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
In order make Relation behavior closer to Array
Made Relation#sum to accept block and delegate it to Array#sum
|
| |
|
|
|
|
| |
RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases.
|
|
|
|
|
|
| |
- If doing a count on a relation that has an :include and a :join, it does a distinct even though it should not.
- When doing a count on a relation that has an :include, it always falls back to a old style left join when performing the count. Looks like it was broken here:
https://github.com/rails/rails/commit/b9599502c9e738a5a1513e75d08f8d40ed408265
|
|\
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* master: (51 commits)
order is not guaranteed by this select, so add an order and call first!
oracle stores this with microseconds, so convert to seconds before comparing
make sure that active connections are not cleared during test when an exception happens
clearing active connections in the ConnectionManagement middleware if an exception happens
proxy body responses so we close database connections after body is flushed
Pass the proper method_name instead of hardcoding to action_name.
Quote find_in_batches ORDER BY clause [#6620 state:resolved]
Delegate first!, last!, any? and many? to scoped
Dont call authenticate_or_request_with_http_basic twice
Remove 'warning: ambiguous first argument' when running ActionPack tests
Change exists? so that it doesn't instantiate records [#6127 state:resolved]
Move mapper_test to the appropriate location
Update the wildcard route to be non-greedy by default, therefore be able to match the (.:format) segment [#6605 state:resolved]
Fix examples
Added Base.http_basic_authenticate_with to do simple http basic authentication with a single class method call [DHH]
make sure we have an active database connection before running each connection management test
adding active_connections? to the connection pool for finding open connections
adding active_connection? to the connection pool
testing app delegation from the ConnectionManagement middleware
namespacing connection management tests. :heart:
...
|
| |
| |
| |
| | |
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
|
| |
| |
| |
| |
| |
| | |
This reverts commit 45c233ef819dc7b67e259dd73f24721fec28b8c8.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
|
| |
| |
| |
| | |
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
|
|/
|
|
| |
counting.
|