Closed jeremysenn closed 4 years ago
Turns out this issue was similar to this one:
https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues/643
I created a custom attribute in an initializer (rails_sqlserver_types.rb):
ActiveRecord::Type.register(:var_binary_max, ActiveRecord::Type::SQLServer::VarbinaryMax)
And then applied the custom attribute in the model:
attribute :jpeg_image, :var_binary_max
Environment
Operating System
ProductName: Mac OS X ProductVersion: 10.15.5 BuildVersion: 19F101
Rails version: 6.0.3 SQL Server adapter version: 6.0.0 SQL Server: 2012
TinyTDS Version and Information
TinyTDS version: 2.1.2
FreeTDS Version
freetds v1.00.21
Description
A table's image/binary type column is being treated as a string type column, which results in the following error when saving blob image data to that column:
ActiveRecord::StatementInvalid: ArgumentError: string contains null byte
The same exact image/binary column is correctly shown as a binary column in earlier versions (SQL Server adapter version 4.1.4 and TinyTDS version 1.0.5), allowing for successful saving of blob image data to the column.