These are chat archives for rails-sqlserver/activerecord-sqlserver-adapter

19th
Oct 2018
Benjamin Fleischer
@bf4
Oct 19 2018 14:01
Going from version 4.2.18 to 5.0.8 (We're of course also upgrading Rails) has broker finder behavior on a table with multiple primary keys, and I'm not sure how to address it. For exampleMyRecord.where(field_name: value).take now fails with ActiveRecord::StatementInvalid:
TinyTds::Error: Invalid column name '"TicketNo", "UniqueID", "ItemNo"'.: EXEC sp_executesql N'SELECT [Tkscale].* FROM [Tkscale] WHERE [Tkscale].[TicketNo] = @0 ORDER BY [Tkscale].["TicketNo", "UniqueID", "ItemNo"] ASC OFFSET 0 ROWS FETCH NEXT @1 ROWS ONLY', N'@0 nvarchar(max), @1 int', @0 = N'10234770', @1 = 1 which is odd since I didn't ask for the ordering. I'm not sure how to fix this. I have set MyRecord.table_name = 'Tkbatch' and MyRecord.primary_key = :UniqueId. MyRecord.connection.schema_cache.primary_keys("Tkbatch") returns ["TicketNo", "UniqueID", "ItemNo"]. I can't find an issue or in the code where this should be addressed. any ideas?
I could get around it by setting a default scope with an order but that's kind of a workaround
Benjamin Fleischer
@bf4
Oct 19 2018 19:47
@metaskills --^