Upgraded activerecord-sqlserver-adapter from 2.2.22 to 2.3.8 and now getting an ODBC error
-
26-09-2019 - |
Question
I have been using MSSQL 2005 with Rails for quite a while now, and decided to bump my gems up on one of my projects and ran into a problem.
I moved from 2.2.22 to 2.3.8 (latest as of writing) and all of a sudden I got this:
ODBC::Error: S1090 (0) [unixODBC][Driver Manager]Invalid string or buffer length
I'm using a DSN connection with FreeTDS my database.yml
looks like this:
adapter: sqlserver
mode: ODBC
dsn: 'DRIVER=FreeTDS;TDSVER=7.0;SERVER=10.0.0.5;DATABASE=db;Port=1433;UID=user;PWD=pwd;'
Now in the mean time I moved back to 2.2.22 and there are no deprecation warnings and everything seems fine but obviously for the sake of being up to date, any ideas what could have changed in the adaptor that could cause this?
Solution
You should use TinyTDS with the adapter, not ODBC. I have TinyTDS support even in the latest 2.3 versions. Here is the wiki page.
https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/Using-TinyTds
The good thing about TinyTDS is that it is tested to return good data from every type on SQL Server and is unicode safe.
OTHER TIPS
I just had a similar problem. Removing the activerecord-sqlserver-adapter and using the activerecord-odbc-adapter (version 2.0). Works for me.
I just uninstalled activerecord-sqlserver-adapter, dbi, and dbd-odbc. And then installed activerecord-odbc-adapter and changed my db config to be something like
your_database:
adapter: odbc
dsn: YourDNS
username: YourUsername
password: YourPassword
Works sweet : )