From 9b852af49783096124aa34c4638b99768f701a78 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 30 Apr 2009 20:33:50 -0700 Subject: Explicitly require builder for to_xml --- activerecord/lib/active_record/validations.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index d2d12b80c9..e6b61e0b35 100644 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -1,3 +1,5 @@ +require 'builder' + module ActiveRecord # Raised by save! and create! when the record is invalid. Use the # +record+ method to retrieve the record which did not validate. -- cgit v1.2.3 From b193f233908823cccd2f1d5fcb4146787ed8c4ed Mon Sep 17 00:00:00 2001 From: Ken Collins Date: Mon, 9 Feb 2009 15:24:59 -0500 Subject: Use table_exists? in #initialize_schema_migrations_table [#1923 state:resolved] Signed-off-by: Pratik Naik --- .../active_record/connection_adapters/abstract/schema_statements.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index c29c1562b4..ff63ea3a2e 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -316,7 +316,7 @@ module ActiveRecord def initialize_schema_migrations_table sm_table = ActiveRecord::Migrator.schema_migrations_table_name - unless tables.detect { |t| t == sm_table } + unless table_exists?(sm_table) create_table(sm_table, :id => false) do |schema_migrations_table| schema_migrations_table.column :version, :string, :null => false end @@ -327,7 +327,7 @@ module ActiveRecord # migrated up to that point: si_table = Base.table_name_prefix + 'schema_info' + Base.table_name_suffix - if tables.detect { |t| t == si_table } + if table_exists?(si_table) old_version = select_value("SELECT version FROM #{quote_table_name(si_table)}").to_i assume_migrated_upto_version(old_version) -- cgit v1.2.3 From 5501b99a19a2a67a9a920fd3c7bff071a2ecf058 Mon Sep 17 00:00:00 2001 From: steve Date: Fri, 1 May 2009 14:58:10 +0100 Subject: Ensure ActiveRecord::Base.connection_pool.with_connection creates a new connection only when needed [#1752 state:resolved] Signed-off-by: Pratik Naik --- .../connection_adapters/abstract/connection_pool.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb index aac84cc5f4..e8e736bf38 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -107,13 +107,14 @@ module ActiveRecord checkin conn if conn end - # Reserve a connection, and yield it to a block. Ensure the connection is - # checked back in when finished. + # If a connection already exists yield it to the block. If no connection + # exists checkout a connection, yield it to the block, and checkin the + # connection when finished. def with_connection - conn = checkout - yield conn + fresh_connection = true unless @reserved_connections[current_connection_id] + yield connection ensure - checkin conn + release_connection if fresh_connection end # Returns true if a connection has already been opened. -- cgit v1.2.3 From db0bfe4ede3cdfc2e4ccdb2a89525a914e6d0913 Mon Sep 17 00:00:00 2001 From: Alexander Podgorbunsky Date: Thu, 26 Mar 2009 15:00:12 +0300 Subject: Default scope :order should be overridden by named scopes. [#2346 state:committed] Signed-off-by: Jeremy Kemper --- activerecord/lib/active_record/named_scope.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/named_scope.rb b/activerecord/lib/active_record/named_scope.rb index 1f3ef300f2..3df7089096 100644 --- a/activerecord/lib/active_record/named_scope.rb +++ b/activerecord/lib/active_record/named_scope.rb @@ -114,7 +114,7 @@ module ActiveRecord end end - delegate :scopes, :with_scope, :to => :proxy_scope + delegate :scopes, :with_scope, :scoped_methods, :to => :proxy_scope def initialize(proxy_scope, options, &block) options ||= {} @@ -178,7 +178,7 @@ module ActiveRecord else with_scope({:find => proxy_options, :create => proxy_options[:conditions].is_a?(Hash) ? proxy_options[:conditions] : {}}, :reverse_merge) do method = :new if method == :build - if current_scoped_methods_when_defined + if current_scoped_methods_when_defined && !scoped_methods.include?(current_scoped_methods_when_defined) with_scope current_scoped_methods_when_defined do proxy_scope.send(method, *args, &block) end -- cgit v1.2.3 From 99c103be1165da9c8299bc0977188ecf167e06a5 Mon Sep 17 00:00:00 2001 From: Ruy Asan Date: Fri, 1 May 2009 13:09:29 -0700 Subject: Fixed bug with polymorphic has_one :as pointing to an STI record [#2594 state:committed] Signed-off-by: Jeremy Kemper --- activerecord/lib/active_record/associations/has_one_association.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/associations/has_one_association.rb b/activerecord/lib/active_record/associations/has_one_association.rb index b92cbbdeab..1464227bb0 100644 --- a/activerecord/lib/active_record/associations/has_one_association.rb +++ b/activerecord/lib/active_record/associations/has_one_association.rb @@ -88,7 +88,7 @@ module ActiveRecord when @reflection.options[:as] @finder_sql = "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_id = #{owner_quoted_id} AND " + - "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote_value(@owner.class.base_class.name.to_s)}" + "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote_value(@owner.class.name.to_s)}" else @finder_sql = "#{@reflection.quoted_table_name}.#{@reflection.primary_key_name} = #{owner_quoted_id}" end -- cgit v1.2.3