diff options
-rw-r--r-- | Gemfile | 2 | ||||
-rw-r--r-- | actionmailer/README.rdoc | 2 | ||||
-rw-r--r-- | actionpack/README.rdoc | 2 | ||||
-rw-r--r-- | activerecord/README.rdoc | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation/calculations.rb | 9 | ||||
-rw-r--r-- | activerecord/test/cases/associations/cascaded_eager_loading_test.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/calculations_test.rb | 11 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/Gemfile | 4 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/assets/assets_generator.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb | 4 |
10 files changed, 28 insertions, 16 deletions
@@ -10,7 +10,7 @@ end gem "coffee-script" gem "sass" -gem "uglifier" +gem "uglifier", :git => 'git://github.com/lautis/uglifier.git' gem "rake", ">= 0.8.7" gem "mocha", ">= 0.9.8" diff --git a/actionmailer/README.rdoc b/actionmailer/README.rdoc index 9b206fbcc7..af9bf40f9e 100644 --- a/actionmailer/README.rdoc +++ b/actionmailer/README.rdoc @@ -157,5 +157,5 @@ API documentation is at Bug reports and feature requests can be filed with the rest for the Ruby on Rails project here: -* https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets +* https://github.com/rails/rails/issues diff --git a/actionpack/README.rdoc b/actionpack/README.rdoc index 1a56c44db5..5db4cff66b 100644 --- a/actionpack/README.rdoc +++ b/actionpack/README.rdoc @@ -338,4 +338,4 @@ API documentation is at Bug reports and feature requests can be filed with the rest for the Ruby on Rails project here: -* https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets +* https://github.com/rails/rails/issues diff --git a/activerecord/README.rdoc b/activerecord/README.rdoc index a27640eac9..3a89446a83 100644 --- a/activerecord/README.rdoc +++ b/activerecord/README.rdoc @@ -219,4 +219,4 @@ API documentation is at Bug reports and feature requests can be filed with the rest for the Ruby on Rails project here: -* https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets +* https://github.com/rails/rails/issues diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index a8a52867ce..0fcae92d51 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -146,7 +146,7 @@ module ActiveRecord if options.except(:distinct).present? apply_finder_options(options.except(:distinct)).calculate(operation, column_name, :distinct => options[:distinct]) else - if eager_loading? || includes_values.present? + if eager_loading? || (includes_values.present? && references_eager_loaded_tables?) construct_relation_for_association_calculations.calculate(operation, column_name, options) else perform_calculation(operation, column_name, options) @@ -161,21 +161,20 @@ module ActiveRecord def perform_calculation(operation, column_name, options = {}) operation = operation.to_s.downcase - distinct = nil + distinct = options[:distinct] if operation == "count" column_name ||= (select_for_count || :all) unless arel.ast.grep(Arel::Nodes::OuterJoin).empty? distinct = true - column_name = primary_key if column_name == :all end + column_name = primary_key if column_name == :all && distinct + distinct = nil if column_name =~ /\s*DISTINCT\s+/i end - distinct = options[:distinct] || distinct - if @group_values.any? execute_grouped_calculation(operation, column_name, distinct) else diff --git a/activerecord/test/cases/associations/cascaded_eager_loading_test.rb b/activerecord/test/cases/associations/cascaded_eager_loading_test.rb index 39e8a7960a..49d8722aff 100644 --- a/activerecord/test/cases/associations/cascaded_eager_loading_test.rb +++ b/activerecord/test/cases/associations/cascaded_eager_loading_test.rb @@ -51,7 +51,9 @@ class CascadedEagerLoadingTest < ActiveRecord::TestCase categories = Category.joins(:categorizations).includes([{:posts=>:comments}, :authors]) assert_nothing_raised do - assert_equal 3, categories.count + assert_equal 4, categories.count + assert_equal 4, categories.all.count + assert_equal 3, categories.count(:distinct => true) assert_equal 3, categories.all.uniq.size # Must uniq since instantiating with inner joins will get dupes end end diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb index 654c4c9010..56f6d795b6 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -319,6 +319,17 @@ class CalculationsTest < ActiveRecord::TestCase assert_equal 4, Account.count(:distinct => true, :include => :firm, :select => :credit_limit) end + def test_should_not_perform_joined_include_by_default + assert_equal Account.count, Account.includes(:firm).count + queries = assert_sql { Account.includes(:firm).count } + assert_no_match(/join/i, queries.last) + end + + def test_should_perform_joined_include_when_referencing_included_tables + joined_count = Account.includes(:firm).where(:companies => {:name => '37signals'}).count + assert_equal 1, joined_count + end + def test_should_count_scoped_select Account.update_all("credit_limit = NULL") assert_equal 0, Account.scoped(:select => "credit_limit").count diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile index a69efdf29d..3af28bb416 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile @@ -9,7 +9,7 @@ source 'http://rubygems.org' <%= "gem 'json'\n" if RUBY_VERSION < "1.9.2" -%> gem 'sass' gem 'coffee-script' -gem 'uglifier' +gem 'uglifier', :git => 'git://github.com/lautis/uglifier.git' <%= gem_for_javascript %> @@ -22,4 +22,4 @@ gem 'uglifier' # To use debugger # <%= gem_for_ruby_debugger %> -<%= gem_for_turn -%>
\ No newline at end of file +<%= gem_for_turn -%> diff --git a/railties/lib/rails/generators/rails/assets/assets_generator.rb b/railties/lib/rails/generators/rails/assets/assets_generator.rb index fb215f91af..2d52da77eb 100644 --- a/railties/lib/rails/generators/rails/assets/assets_generator.rb +++ b/railties/lib/rails/generators/rails/assets/assets_generator.rb @@ -2,10 +2,10 @@ module Rails module Generators class AssetsGenerator < NamedBase class_option :javascripts, :type => :boolean, :desc => "Generate JavaScripts" - class_option :stylesheets, :type => :boolean, :desc => "Generate stylesheets" + class_option :stylesheets, :type => :boolean, :desc => "Generate Stylesheets" class_option :javascript_engine, :desc => "Engine for JavaScripts" - class_option :stylesheet_engine, :desc => "Engine for stylesheets" + class_option :stylesheet_engine, :desc => "Engine for Stylesheets" def create_javascript_files return unless options.javascripts? diff --git a/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb index 6eef0dbe5b..aa9b45c5a5 100644 --- a/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb +++ b/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb @@ -6,8 +6,8 @@ module Rails remove_hook_for :resource_controller remove_class_option :actions - class_option :stylesheets, :type => :boolean, :desc => "Generate stylesheets" - class_option :stylesheet_engine, :desc => "Engine for stylesheets" + class_option :stylesheets, :type => :boolean, :desc => "Generate Stylesheets" + class_option :stylesheet_engine, :desc => "Engine for Stylesheets" hook_for :scaffold_controller, :required => true |