SQLServer: resolve column aliasing/quoting collision when using limit or offset in an eager find. References #2974.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3184 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jeremy Kemper
2005-11-24 07:15:00 +00:00
parent 2b28575734
commit 6c1a356a1a
2 changed files with 8 additions and 1 deletions

View File

@@ -1,5 +1,7 @@
*SVN*
* SQLServer: resolve column aliasing/quoting collision when using limit or offset in an eager find. #2974 [kajism@yahoo.com]
* Reloading a model doesn't lose track of its connection. #2996 [junk@miriamtech.com, Jeremy Kemper]
* Fixed bug where using update_attribute after pushing a record to a habtm association of the object caused duplicate rows in the join table. #2888 [colman@rominato.com, Florian Weber]

View File

@@ -356,7 +356,12 @@ module ActiveRecord
if options[:order]
options[:order] = options[:order].split(',').map do |field|
parts = field.split(" ")
if sql =~ /#{parts[0]} AS (t\d_r\d\d?)/
tc = parts[0]
if sql =~ /\.\[/ and tc =~ /\./ # if column quoting used in query
tc.gsub!(/\./, '\\.\\[')
tc << '\\]'
end
if sql =~ /#{tc} AS (t\d_r\d\d?)/
parts[0] = $1
end
parts.join(' ')