aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-02-20 03:15:22 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-02-20 03:15:22 +0000
commit377bdd02b9daba35113299262a98060763925959 (patch)
treec5db590773c64d334b81a42291d01a6030c1fc84 /activerecord/lib/active_record/base.rb
parent03acf48817d38e8ec4078d50f6ab48a2dfc035b3 (diff)
downloadrails-377bdd02b9daba35113299262a98060763925959.tar.gz
rails-377bdd02b9daba35113299262a98060763925959.tar.bz2
rails-377bdd02b9daba35113299262a98060763925959.zip
Added :count option to pagination that'll make it possible for the ActiveRecord::Base.count call to using something else than * for the count. Especially important for count queries using DISTINCT #3839 [skaes]. Added :select option to Base.count that'll allow you to select something else than * to be counted on. Especially important for count queries using DISTINCT (closes #3839) [skaes].
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3620 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-xactiverecord/lib/active_record/base.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index deb3c5fc1f..e040c86505 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -544,7 +544,7 @@ module ActiveRecord #:nodoc:
def construct_counter_sql(options)
sql = "SELECT COUNT("
sql << "DISTINCT " if options[:distinct]
- sql << "#{table_name}.#{primary_key}) FROM #{table_name} "
+ sql << "#{options[:select] || "#{table_name}.#{primary_key}"}) FROM #{table_name} "
sql << " #{options[:joins]} " if options[:joins]
add_conditions!(sql, options[:conditions])
sql