These are chat archives for rails-sqlserver/activerecord-sqlserver-adapter
Hi, would anyone have insight into the following odd behaviour?
I'm using a new Rails app to test this issue, so I create a migration:
create_table :users do |t| t.string :code, unique: true, limit: 5 end
After this I can
User.create(code: 'ABCDE'). Now, if I then run
User.find_by(code: 'ABCDEF'), I would expect nil to be returned (as is the case with MySQL), however, it is returning that user I just created.
Note: with this
limit in place, a
code with more than 5 characters is truncated on saving, so '1234567' would be saved as '12345'.
I'm running OSX 10.11.5, Rails 4.2.6, freetds 1.00, tiny_tds 1.0.4, and activerecord-sqlserver-adapter 4.2.15. Connecting to SQL Server 2012.
"SELECT [users].* FROM [users] WHERE [users].[code] = N'ABCDEF'"
#<ActiveRecord::Relation [#<User id: 2, code: "ABCDE">]>
User.where(code:'ABCDEF')that was the result