Project

General

Profile

Actions

Defect #19149

closed

TinyTDS generates SQL for wrong version of MS SQL

Added by Serghei Zagorinyak almost 10 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Database
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

After upgrading an instance of Redmine 2.6.0 to 3.0.0 I have encountered the following problem: while running on MS SQL 2008 server, Redmine generates queries for MS SQL 2012 which results in syntax errors.

Example:

TinyTds::Error: Incorrect syntax near 'OFFSET'.: EXEC sp_executesql N'SELECT [settings].* FROM [settings] WHERE [settings].[name] = @0 
ORDER BY [settings].[id] DESC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY', N'@0 nvarchar(255)', @0 = N'rest_api_enabled'

Extracted source (around line 246):

#app/models/setting.rb
name = name.to_s
raise "There's no setting named #{name}" unless available_settings.has_key?(name)
setting = where(:name => name).order(:id => :desc).first
unless setting
setting = new
setting.name = name

The OFFSET option is unavailable in MS SQL 2008

Actions

Also available in: Atom PDF