Binary column

11 views
Skip to first unread message

Renato Serra

unread,
Jun 15, 2015, 10:51:38 AM6/15/15
to rails-sqlse...@googlegroups.com
Hi guys,

I need some help :)
I got a SQL server 2008 database and currently using sqlserver-adapter 4.1.0.
When i try to insert my data to the database it generates this query:

EXEC sp_executesql N'INSERT INTO [user_auth] ([account], [answer1], [answer2], [password], [quiz1], [quiz2]) OUTPUT inserted.account VALUES (@0, @1, @2, @3, @4, @5)', N'@0 varchar(14), @1 binary, @2 binary, @3 binary, @4 varchar(255), @5 varchar(255)', @0 = N'fafa', @1 = 0x, @2 = 0x, @3 = 0xb539dbbe3f081cb88d143232ff654343, @4 = N'', @5 = N''  [["account", "fafa"], ["answer1", "<0 bytes of binary data>"], ["answer2", "<0 bytes of binary data>"], ["password", "<16 bytes of binary data>"], ["quiz1", ""], ["quiz2", ""]]

The thing is the column for password in the database is a Binary(16) and the generated query is sending a Binary (default 1) which cuts my string.

What are the possible ways for me to fix this?

Thank you!!

Renato

Ken Collins

unread,
Jul 8, 2015, 7:53:58 AM7/8/15
to rails-sqlse...@googlegroups.com, renat....@gmail.com
Hey Renato, I am not working on the 4-1-stable branch (https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/4-1-stable) but please feel free to submit a patch for this. We have a pretty good setup for tests and a nice doc on how to contribute (https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/4-1-stable/RUNNING_UNIT_TESTS.md). 

I would look at the `string_to_binary` method maybe. FWIW, this could be something that ActiveRecord or the 4-1-x adapter is not set to handle. Perhaps you should run a validation in your model that creates the necessary values if the length is not right?
Reply all
Reply to author
Forward
0 new messages