提交 dbe8a26d 编写于 作者: D David Heinemeier Hansson

Fixed that options[:counter_sql] was overwritten with interpolated sql rather...

Fixed that options[:counter_sql] was overwritten with interpolated sql rather than original sql #355 [bitsweat]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@248 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 91eaeb28
*SVN*
* Fixed that options[:counter_sql] was overwritten with interpolated sql rather than original sql #355 [bitsweat]
* Fixed that overriding an attribute's accessor would be disregarded by add_on_empty and add_on_boundary_breaking because they simply used
the attributes[] hash instead of checking for @base.respond_to?(attr.to_s). [Marten]
......
......@@ -14,7 +14,8 @@ def initialize(owner, association_name, association_class_name, association_clas
if options[:counter_sql]
@counter_sql = interpolate_sql(options[:counter_sql])
elsif options[:finder_sql]
@counter_sql = options[:counter_sql] = @finder_sql.gsub(/SELECT (.*) FROM/i, "SELECT COUNT(*) FROM")
options[:counter_sql] = options[:finder_sql].gsub(/SELECT (.*) FROM/i, "SELECT COUNT(*) FROM")
@counter_sql = interpolate_sql(options[:counter_sql])
else
@counter_sql = "#{@association_class_primary_key_name} = #{@owner.quoted_id}#{@conditions ? " AND " + interpolate_sql(@conditions) : ""}"
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册