Skip to content
Browse files

r3315@asus: jeremy | 2005-11-23 23:13:48 -0800

 Apply [3184] to stable.  SQLServer: resolve column aliasing/quoting collision when using limit or offset in an eager find.  Closes #2974.


git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/stable@3185 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 1dc4783 commit 6865b666211aae2b66449281e7b360bea3d3254d @jeremy jeremy committed Nov 24, 2005
View
2 activerecord/CHANGELOG
@@ -2,6 +2,8 @@
* Introducing the Firebird adapter. Quote columns and use attribute_condition more consistently. Setup guide: http://wiki.rubyonrails.com/rails/pages/Firebird+Adapter #1874 [Ken Kunz <kennethkunz@gmail.com>]
+* 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
7 activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb
@@ -330,7 +330,12 @@ def add_limit_offset!(sql, options)
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(' ')

0 comments on commit 6865b66

Please sign in to comment.
Something went wrong with that request. Please try again.