aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorMarcel Molina <marcel@vernix.org>2005-10-11 03:40:11 +0000
committerMarcel Molina <marcel@vernix.org>2005-10-11 03:40:11 +0000
commitdcc2263b3a500caf06d08a109d8fb6e9d226b7fb (patch)
tree07536ca9a6f713ec4435ff1ef90a9121bb7ecfa6 /activerecord
parent31ae8121e47e69f667df1ef86bff8f61e9f860cc (diff)
downloadrails-dcc2263b3a500caf06d08a109d8fb6e9d226b7fb.tar.gz
rails-dcc2263b3a500caf06d08a109d8fb6e9d226b7fb.tar.bz2
rails-dcc2263b3a500caf06d08a109d8fb6e9d226b7fb.zip
Speed up for unthreaded environments. Closes #2431.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2530 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG4
-rwxr-xr-xactiverecord/lib/active_record/base.rb22
2 files changed, 20 insertions, 6 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 52af1ea816..c9c7063a62 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,6 +1,8 @@
*SVN*
-* Optimization for Mysql selects using mysql-ruby extension greater than 2.6.3. #2426. [skaes.web.de]
+# Speed up for unthreaded environments. #2431. [skaes@web.de]
+
+* Optimization for Mysql selects using mysql-ruby extension greater than 2.6.3. #2426. [skaes@web.de]
* Speed up the setting of table_name. #2428. [skaes@web.de]
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index ab9b5d6221..b31844d1b7 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -235,7 +235,11 @@ module ActiveRecord #:nodoc:
# also be used to "borrow" the connection to do database work unrelated
# to any of the specific Active Records.
def self.connection
- retrieve_connection
+ if @@threaded_connections
+ retrieve_connection
+ else
+ @connection ||= retrieve_connection
+ end
end
# Returns the connection currently associated with the class. This can
@@ -928,15 +932,23 @@ module ActiveRecord #:nodoc:
end
def scope_constraints
- Thread.current[:constraints] ||= {}
- Thread.current[:constraints][self] ||= {}
+ if @@threaded_connections
+ Thread.current[:constraints] ||= {}
+ Thread.current[:constraints][self] ||= {}
+ else
+ @scope_constraints ||= {}
+ end
end
# backwards compatibility
alias_method :scope_constrains, :scope_constraints
def scope_constraints=(value)
- Thread.current[:constraints] ||= {}
- Thread.current[:constraints][self] = value
+ if @@threaded_connections
+ Thread.current[:constraints] ||= {}
+ Thread.current[:constraints][self] = value
+ else
+ @scope_constraints = value
+ end
end
# backwards compatibility
alias_method :scope_constrains=, :scope_constraints=