These are chat archives for rails-sqlserver/activerecord-sqlserver-adapter
Hi Ken, the issue seems related to stored procedures, which is how the SQL is constructed. Here's the final statement that's passed to
EXEC sp_executesql N'SELECT [users].* FROM [users] WHERE [users].[code] = @0 ORDER BY [users].[id] ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY', N'@0 nvarchar(5)', @0 = N'123456'
What's happening in MSSQL itself is that
123456 is being truncated because of the
nvarchar(5) - this seems to be known behaviour. Here's an SO post which gives a nice overview: http://stackoverflow.com/questions/4628140/sql-server-silently-truncates-varchars-in-stored-procedures
The proposed solution there is to use
nvarchar(max), even though there would be a small performance hit. With this change
INSERTs using the GEM would not truncate (ActiveRecord validations on
length would kick in). And the
.find_by would fail as expected.
I don't see how to move forward with this. Do you have any thoughts?