rails-sqlserver / activerecord-sqlserver-adapter

SQL Server Adapter For Rails
MIT License
972 stars 559 forks source link

ActiveRecord::StatementInvalid: TinyTds::Error: Incorrect syntax near '0' #843

Open aet08 opened 4 years ago

aet08 commented 4 years ago

Issue

irb(main):001:0> UserT.count SQL (4.9ms) USE [GenDB] (5.5ms) SELECT COUNT(*) FROM [UserT] => 2

irb(main):003:0> UserT.first UserT Load (9.6ms) EXEC sp_executesql N'SELECT [UserT]. FROM [UserT] OFFSET 0 ROWS FETCH NEXT @0 ROWS ONLY', N'@0 int', @0 = 1 [["LIMIT", nil]] ActiveRecord::StatementInvalid: TinyTds::Error: Incorrect syntax near '0'.: EXEC sp_executesql N'SELECT [UserT]. FROM [UserT] OFFSET 0 ROWS FETCH NEXT @0 ROWS ONLY', N'@0 int', @0 = 1 from (irb):3

Expected behavior

Should return first record for UserT

Actual behavior

UserT Load (9.6ms) EXEC sp_executesql N'SELECT [UserT]. FROM [UserT] WHERE [UserT].[id] = @0', N'@0 int', @0 = 1 [["id", nil]] ActiveRecord::StatementInvalid: TinyTds::Error: Invalid column name 'id'.: EXEC sp_executesql N'SELECT [UserT]. FROM [UserT] WHERE [UserT].[id] = @0', N'@0 int', @0 = 1 from (irb):3

How to reproduce

Details

aidanharan commented 3 years ago

Unable to recreate the issue. Could you provide a test case (https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/main/test/cases) or more information on the issue?