aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/null_relation.rb
Commit message (Collapse)AuthorAgeFilesLines
* Fixed a problem where `sum`, `size`, `average`, `minimum` and `maximum` usedKuldeep Aggarwal2014-05-151-3/+17
| | | | with a grouping was not returning a Hash.
* Changed the NullRelation so that when count is called with #group it will ↵Eric Chahin2014-04-161-2/+2
| | | | | | | properly return an empty hash instead of zero. Fixes issue #14721 Conflicts: activerecord/CHANGELOG.md
* Mark the arguments needed by activerecord-deprecated_finders with a TODORafael Mendonça França2013-12-111-2/+4
|
* Revert "Merge pull request #12518 from vipulnsward/remove_count_options"Rafael Mendonça França2013-12-111-1/+1
| | | | | | | It is needed for activerecord-depecated_finders This reverts commit dcff027a5242b20c0c90eb062dddb22ccf51aed9, reversing changes made to 3a2093984ff49d86db1efeff0c7581e788ecfb9f.
* Pluck on NullRelation accepts a list of columnsDerek Prior2013-10-151-1/+1
| | | | | | `pluck` was updated to accept a list of columns, but the `NullRelation` was never updated to match that signature. As a result, calling `pluck` on a `NullRelation` results in an `ArgumentError`.
* Stop accepting `options` for `Relation#average`, `Relation#minimum`, ↵Vipul A M2013-10-141-1/+1
| | | | `Relation#maximum`, `Relation#calculate`, `perform_calculation`, `NullRelation#calculate` as they isn't used anymore.
* Removed where_values_hash from AR::NullRelationPaul Nikitochkin2013-09-281-4/+0
| | | | | | | | | | | | | | | | | | | In order to build associated records for owners which has not been saved need to get where values to use as default attributes. But for new record owner uses `ActiveRecord::NullRelation` which override `where_values_hash` to return empty hash stub. `where_values_hash` is not used to invoke any sql query, but good to build others chains (even will be never executed) like: ```ruby post = Post.new admin_comment = post.admin_comments.build assert_equal 'Admin', admin_comment.author ``` Closes #11376, #11676, #11675
* Make NullRelation a bit more like a real relation by returning 0 for ↵Ben Woosley2013-05-101-1/+5
| | | | #calculate(:count)
* No point in memoizing a simple literal string.Ben Woosley2013-05-101-1/+1
|
* Delegate all calculations to the scope.Jon Leighton2012-11-091-0/+4
| | | | | | | So that the scope may be a NullRelation and return a result without executing a query. Fixes #7928
* Nullify the relation at a more general level.Jon Leighton2012-11-091-1/+1
| | | | | | | | | | | | | | | This allows us to avoid hacks like the "return 0 if owner.new_record?" in #count (which this commit removes). Also, the relevant foreign key may actually be present even on a new owner record, in which case we *don't* want a null relation. This logic is encapsulated in the #null_scope? method. We also need to make sure that the CollectionProxy is not 'infected' with the NullRelation module, or else the methods from there will override the definitions in CollectionProxy, leading to incorrect results. Hence the nullify: false option to CollectionAssociation#scope. (This feels a bit nasty but I can't think of a better way.)
* improve NullRelation docs [ci skip]Vijay Dev2012-07-211-1/+0
|
* Fix typos and add nodocs to NullRelationOscar Del Ben2012-07-171-1/+1
|
* unused method argumentsAkira Matsuda2012-06-011-7/+6
|
* modulize AR::NullRelationAkira Matsuda2012-06-011-2/+2
| | | | now we can invoke previously added scope extension methods
* Override AR::Relation methods in NullRelation.Juanjo Bazán2012-04-111-0/+53
| | | So a NullRelation (Relation#none) is chainable with database methods.
* Added `none` query method to return zero records.Juanjo Bazán2012-01-311-0/+10
And added NullRelation class implementing the null object pattern for the `Relation` class.