aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/calculations_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Stop assuming strings for grouped calculationsErnie Miller2012-06-241-0/+5
| | | | | | | | | | | | | | | 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.
* Refactor pluck with multiple columnsCarlos Antonio da Silva2012-06-221-10/+16
| | | | | | | | | | | | 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-1/+16
|
* Extract conditional to a method to avoid duplicationRafael Mendonça França2012-06-191-0/+3
| | | | Also use if/else block to not use short circuit return
* handle joins/includes correctly for pluck and calculation.Andrey Deryabin2012-06-191-0/+43
| | | | Fix #5990
* Allow blocks for count with ActiveRecord::Relation. Document and test that ↵chrisfinne2012-05-281-0/+16
| | | | sum allows blocks
* MySQL returns "SUM(DISTINCT(credit_limit))" as the column name unlessAaron Patterson2012-05-161-1/+5
| | | | | an alias is provided. Without the alias, the column cannot be found and properly typecast.
* Fixes issue where SQL fragments prevented type casting based on column type.Erich Menge2012-05-161-0/+3
|
* Restore support for Model.pluck('sql fragment')Jeremy Kemper2012-05-151-0/+8
|
* Fix PR #6091Andrew White2012-04-301-1/+1
| | | | | | 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
* Add ActiveRecord::Base#idstwinturbo2012-04-301-0/+4
|
* remove deprecate #calculate callsJon Leighton2012-04-261-76/+59
|
* remove tests for #with_scope (it's now deprecated)Jon Leighton2012-04-251-6/+0
|
* fix testsJon Leighton2012-04-131-5/+5
|
* typecast columns based on the returned typesAaron Patterson2012-02-091-6/+1
|
* PostgreSQL does not work in the same way of the other adaptersRafael Mendonça França2012-02-081-3/+7
|
* AR::Relation#pluck: improve to work with joinsBogdan Gusiev2012-02-081-0/+11
|
* Deprecate inferred JOINs with includes + SQL snippets.Jon Leighton2012-01-161-3/+3
| | | | | | See the CHANGELOG for details. Fixes #950.
* Revert "Deprecate implicit eager loading. Closes #950."Jon Leighton2012-01-161-6/+4
| | | | This reverts commit c99d507fccca2e9e4d12e49b4387e007c5481ae9.
* Deprecate implicit eager loading. Closes #950.Jon Leighton2011-12-291-4/+6
|
* Make ActiveRecord::Relation#pluck work with serialized attributesJon Leighton2011-12-221-1/+8
|
* ActiveRecord::Relation#pluck methodBogdan Gusiev2011-11-301-0/+25
|
* pg does not allow aliases in the having clause, but functions are fineAaron Patterson2011-08-051-1/+1
|
* Fixed failing query when performing calculation with having based on select.Dmitriy Kiriyenko2011-07-271-0/+7
|
* Fixed AR::Relation#sum compatibility with Array#sumBogdan Gusiev2011-07-051-0/+4
| | | | | In order make Relation behavior closer to Array Made Relation#sum to accept block and delegate it to Array#sum
* please use ruby -I lib:test path/to/test.rb, or export RUBY_OPTAaron Patterson2011-06-061-1/+1
|
* Refactor Active Record test connection setup. Please see the ↵Jon Leighton2011-06-041-1/+1
| | | | 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.
* Bug fixes:Fadzril Muhamad & Joseph Palermo2011-05-121-0/+11
| | | | | | - 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
* Merge branch 'master' into zomgAaron Patterson2011-03-291-2/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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: ...
| * Added new #update_column method.Sebastian Martinez2011-03-271-2/+2
| | | | | | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
| * Revert "Removed #update_attribute method. New #update_column method."Sebastian Martinez2011-03-271-2/+2
| | | | | | | | | | | | This reverts commit 45c233ef819dc7b67e259dd73f24721fec28b8c8. Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
| * Removed #update_attribute method. New #update_column method.Sebastian Martinez2011-03-261-2/+2
| | | | | | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* | Change behavior of count(:limit => x, :offset => y) to limit/offset before ↵John Mileham2011-03-031-11/+26
|/ | | | counting.
* skip this on oracleAaron Patterson2011-02-281-0/+2
|
* removing limits and offsets from COUNT queries unless both are specified. ↵Aaron Patterson2011-02-251-0/+28
| | | | [#6268 state:resolved]
* The type_cast_calculated_value method will trust DB types before casting to ↵Ken Collins2011-02-031-0/+6
| | | | | | | | a BigDecimal. [#6365 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Always return decimal average of integer fieldsRaimonds Simanovskis2011-01-101-0/+5
| | | | In previous version if database adapter (e.g. SQLite and Oracle) returned non-String calculated values then type_cast_using_column converted decimal average value of intefer field to integer value. Now operation parameter is always checked to decide which conversion of calculated value should be done.
* Fix ActiveRecord calculations when grouped by multiple fieldsAlexandru Catighera2010-11-161-0/+13
|
* Honor distinct option when used with count operation after group clause ↵Marcelo Giorgi2010-10-111-0/+9
| | | | [#5721 state:resolved]
* group clause must be more specificAaron Patterson2010-09-301-1/+1
|
* Tests proving #5441oleg dashevskii2010-09-301-1/+11
|
* update tests for mysql2 supportBrian Lopez2010-08-021-1/+1
|
* Add tests for relation count. Fix other tests that were conceptually wrong.Emilio Tagua2010-06-241-1/+1
| | | | | | [#4882 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Refactor calculation test to remove unneeded SQLite special case.Santiago Pastorino2010-05-241-4/+1
| | | | | | [#4633] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* type_cast_calculated_value refactor: value is never a Fixnum here. Fix test ↵Santiago Pastorino2010-05-111-2/+1
| | | | | | | | since SQLite returns Float. [#4514 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Fix associations to call :destroy or :delete based on the right :dependent ↵Carlos Antonio da Silva2010-03-091-2/+2
| | | | | | option Signed-off-by: José Valim <jose.valim@gmail.com>
* future proofing the sqlite3 adapter codeAaron Patterson2010-01-261-0/+3
| | | | Signed-off-by: Yehuda Katz <wycats@Yehuda-Katz.local>
* Add Relation#construct_relation_for_association_calculations for ↵Pratik Naik2010-01-191-17/+0
| | | | calculations with includes
* Migrate all the calculation methods to RelationPratik Naik2009-12-291-10/+8
|
* Don't publicize with_scope for tests since it may shadow public misuseJeremy Kemper2009-12-281-1/+1
|