aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/calculations.rb
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove fall back and column restrictions for `count`.Yves Senn2013-06-091-10/+6
|
* Merge pull request #10561 from Empact/nix-throwresultJon Leighton2013-06-071-2/+0
|\ | | | | Rather than raising ThrowResult when construct_limited_ids_conditions comes up empty, set the relation to NullRelation and rely on its results.
| * Rather than raising ThrowResult when construct_limited_ids_conditions comes ↵Ben Woosley2013-05-101-4/+0
| | | | | | | | | | | | up empty, set the relation to NullRelation and rely on its results. This will help avoid errors like 2fcafee250ee2, because in most cases NullRelation will do the right thing. Minor bonus is avoiding the use of exceptions for flow control.
| * Fix that #pluck wasn't rescuing ThrowResult, meaning it would blow up when ↵Ben Woosley2013-05-101-0/+2
| | | | | | | | failing to construct_limited_ids_condition.
* | Remove #sum with a block was deprecated.kennyj2013-06-011-9/+1
|/
* Handle aliased attributes in ActiveRecord::Relation.Godfrey Chan2013-05-011-8/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | When using symbol keys, ActiveRecord will now translate aliased attribute names to the actual column name used in the database: With the model class Topic alias_attribute :heading, :title end The call Topic.where(heading: 'The First Topic') should yield the same result as Topic.where(title: 'The First Topic') This also applies to ActiveRecord::Relation::Calculations calls such as `Model.sum(:aliased)` and `Model.pluck(:aliased)`. This will not work with SQL fragment strings like `Model.sum('DISTINCT aliased')`. Github #7839 *Godfrey Chan*
* Prefer find_by over dynamic finders in rdocSam Ruby2013-04-021-1/+1
|
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2013-03-301-1/+1
|\ | | | | | | | | | | | | | | | | Conflicts: activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb activerecord/test/cases/adapter_test.rb guides/source/testing.md [ci skip]
| * Uniq cannot be used directly on an ActiveRecord model. 'DISTINCT field' is ↵Daniel Lobato2013-03-121-1/+1
| | | | | | | | the only pluck query that translates into the aforementioned SQL
* | Deprecate the `:distinct` option for `Relation#count`.Yves Senn2013-03-151-2/+7
| | | | | | | | | | | | | | 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.
* | rename `Relation#uniq` to `Relation#distinct`. `#uniq` still works.Yves Senn2013-03-151-2/+2
|/ | | | | | | | 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`.
* copy edits [ci skip]Vijay Dev2013-02-151-1/+1
|
* Add ActiveRecord.count documentation when used on group relationsMaurizio De Santis2013-02-071-0/+6
|
* `#count` in conjunction with `#uniq` performs distinct count.Yves Senn2013-01-261-1/+2
| | | | closes #6865
* Revert "Merge pull request #8989 from robertomiranda/use-rails-4-find-by"Guillermo Iguaran2013-01-181-1/+1
| | | | | This reverts commit 637a7d9d357a0f3f725b0548282ca8c5e7d4af4a, reversing changes made to 5937bd02dee112646469848d7fe8a8bfcef5b4c1.
* User Rails 4 find_byrobertomiranda2013-01-181-1/+1
|
* These are already required through AS/railsAkira Matsuda2013-01-071-2/+0
| | | | | | * dependencies/autoload * concern * deprecation
* warning removed: shadowing outer local variableArun Agrawal2012-12-301-2/+2
|
* fix time typcasting on group counts in PGAaron Patterson2012-12-281-2/+5
|
* mysql does not return alias names, so fall backAaron Patterson2012-12-281-4/+10
|
* fix PG typecasting errorsAaron Patterson2012-12-281-2/+5
|
* Cleans and removes useless 'Examples' tag [ci skip]Alvaro Pereyra2012-12-011-7/+2
|
* copy edits [ci skip]Vijay Dev2012-12-011-1/+1
|
* Fix Calculations#pluck doc to mention several attributes can be selected [ci ↵Florent Guilleux2012-12-011-3/+3
| | | | skip]
* Deprecate Relation#sum with a block.Carlos Antonio da Silva2012-11-211-0/+6
| | | | | | | To perform a sum calculation over the array of elements, use to_a.sum(&block). Please check the discussion in f9cb645dfcb5cc89f59d2f8b58a019486c828c73 for more context.
* Revert "Yield only one argument instead of splatting."Carlos Antonio da Silva2012-11-211-14/+3
| | | | | | | | | | | | | | 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
* Remove not used require and some useless test commentsCarlos Antonio da Silva2012-11-171-2/+0
|
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-11-171-1/+1
|\ | | | | | | | | Conflicts: actionpack/lib/action_dispatch/routing/redirection.rb
| * 1.9 Syntax related changesAvnerCohen2012-11-101-1/+1
| |
* | arel columns can be used for grouping so that "weird" column names are usableAaron Patterson2012-11-151-0/+4
| |
* | stop hardcoding FrontBase adapter conditionalsAaron Patterson2012-11-151-1/+1
| |
* | stop passing *args to generate aliasesAaron Patterson2012-11-151-4/+2
| |
* | create fewer relation objectsAaron Patterson2012-11-151-3/+6
| |
* | `#pluck` can be used on a relation with `select` clause.Yves Senn2012-11-121-1/+3
|/ | | | Closes #7551
* use columns hash to look up the column for the count fieldAaron Patterson2012-10-171-1/+1
|
* ActiveRecord: sum expression returns string '0' for no records, fixedTim Macfarlane2012-10-151-1/+1
|
* Fix pluck when columns/tables are reserved words.Ian Lesperance2012-09-051-1/+1
|
* load active_support/core_ext/object/blank in active_support/railsXavier Noria2012-08-021-1/+0
|
* Ensure Arel columns are typecasted properly when grouping with calculationCarlos Antonio da Silva2012-06-251-6/+6
| | | | Fix build issue with postgresql.
* Stop assuming strings for grouped calculationsErnie Miller2012-06-241-6/+17
| | | | | | | | | | | | | | | 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.
* Add changelog entry and guide updates for pluck with multiple columnsCarlos Antonio da Silva2012-06-221-0/+1
|
* Refactor pluck with multiple columnsCarlos Antonio da Silva2012-06-221-26/+13
| | | | | | | | | | | | 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
* ActiveRecord#pluck now accepts multiple columnsjeroeningen2012-06-221-15/+35
|
* Extract conditional to a method to avoid duplicationRafael Mendonça França2012-06-191-15/+19
| | | | Also use if/else block to not use short circuit return
* handle joins/includes correctly for pluck and calculation.Andrey Deryabin2012-06-191-1/+6
| | | | Fix #5990
* Fix wrong example for count method with block [ci skip]Carlos Antonio da Silva2012-05-311-1/+1
| | | | Thanks @splattael.
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-05-301-1/+1
|\
| * "a sql" -> "an SQL" per API documentation guidelinesMark Rushakoff2012-05-271-1/+1
| |
* | Yield only one argument instead of splatting.Carlos Antonio da Silva2012-05-281-2/+2
| | | | | | | | Add Changelog entry. Closes #4003
* | Allow blocks for count with ActiveRecord::Relation. Document and test that ↵chrisfinne2012-05-281-3/+14
|/ | | | sum allows blocks