This project is archived and is in readonly mode.

#6280 ✓stale
Brian Dunn

Arel should use TOP in updates with a limit on SQL Server

Reported by Brian Dunn | January 12th, 2011 @ 05:06 AM

When connected to SQL Server, with a Gemfile that says this

  gem 'arel', :git => 'git://'

Doing this


Will throw an exception like this

ActiveRecord::StatementInvalid: TinyTds::Error: The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.: UPDATE [users] SET name='brian' WHERE [users].[id] IN (SELECT [users].[id] FROM [users]  ORDER BY id )

Also this


Will silently fail to limit the number of records updated.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

People watching this ticket