Skip to content

Commit

Permalink
Fix Dataset#limit on MSSQL 2000
Browse files Browse the repository at this point in the history
This was broken when support to allow limit to be a bound variable
was added.  Now Sequel will use TOP(N) for MSSQL 2000, and TOP (N)
for MSSQL 2005+.  Tested on MSSQL 2000 and MSSQL 2008.
  • Loading branch information
jeremyevans committed Mar 19, 2010
1 parent 2d25ecf commit dd1b39f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/sequel/adapters/shared/mssql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,14 @@ def select_into_sql(sql)
sql << " INTO #{table_ref(@opts[:into])}" if @opts[:into]
end

# MSSQL uses TOP for limit
# MSSQL uses TOP N for limit. For MSSQL 2005+ TOP (N) is used
# to allow the limit to be a bound variable.
def select_limit_sql(sql)
sql << " TOP (#{literal(@opts[:limit])})" if @opts[:limit]
if l = @opts[:limit]
l = literal(l)
l = "(#{l})" if server_version >= 9000000
sql << " TOP #{l}"
end
end

# Support different types of locking styles
Expand Down

0 comments on commit dd1b39f

Please sign in to comment.