提交 dcc2263b 编写于 作者: M Marcel Molina

Speed up for unthreaded environments. Closes #2431.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2530 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 31ae8121
*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]
......
......@@ -235,7 +235,11 @@ class Base
# 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 @@ def subclasses
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=
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册