On Mar 11, 4:24 am, Gary Doades <[email protected]> wrote: > There is a problem with sequel and MS SQL Server 2000. > > If I have a piece of sequel like this: > > user = self.filter(:username => username).first > > it generates this SQL: > > SELECT TOP (1) * FROM [WRUSER] WHERE ([USERNAME] = N'user1') > > It's the TOP (1) that SQL Server 2000 doesn't like, it likes it as TOP > 1 (i.e. without the brackets). > > SQLServer 2005 and 2008 also like the TOP 1 without the brackets so > I'd like to know if it would be possible to change the SQL generation > in this case to make it compatible with all 3 versions of SQL Server. > We are trying to move to 2008 but all 230 of our production databases > are currently 2000 :(
This was a recent change in Sequel (between 3.8.0 and 3.9.0). It was done to allow you to make the limit a bound variable in a prepared statement, which doesn't work without the parentheses in 2008 (and I think 2005 as well). I'll accept a patch to the shared MSSQL adapter that omits the parentheses if we detect that we are working on a pre-2005 MSSQL. In the mean time, it should be fairly easy to monkey patch, see http://github.com/jeremyevans/sequel/blob/master/lib/sequel/adapters/shared/mssql.rb#L434. Also, you should know that I don't test on MSSQL 2000 (only on 2008). At the very least, limit with an offset is also broken on MSSQL 2000, and that isn't possible to fix correctly in all cases. Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
