activerecord-sqlserver-adapter icon indicating copy to clipboard operation
activerecord-sqlserver-adapter copied to clipboard

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

Open aet08 opened this issue 5 years ago • 1 comments

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

  • Rails version: 5.2.4.3

  • SQL Server adapter version: x.x.x

  • TinyTDS version: x.x.x

  • FreeTDS details:

Compile-time settings (established with the "configure" script) Version: freetds v1.00.82 freetds.conf directory: /etc/freetds MS db-lib source compatibility: no Sybase binary compatibility: yes Thread safety: yes iconv library: yes TDS version: 4.2 iODBC: no unixodbc: yes SSPI "trusted" logins: no Kerberos: yes OpenSSL: no GnuTLS: yes MARS: no


aet08 avatar Aug 09 '20 19:08 aet08

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?

aidanharan avatar Jul 19 '21 13:07 aidanharan