rails-sqlserver / tiny_tds

TinyTDS - Simple and fast FreeTDS bindings for Ruby using DB-Library.
Other
607 stars 189 forks source link

Impossible to avoid use_utf16 option warning on older FreeTDS versions #410

Closed jeremyevans closed 6 years ago

jeremyevans commented 6 years ago

tiny_tds forces the :use_utf16 value to true or false before calling connect (https://github.com/rails-sqlserver/tiny_tds/blob/master/lib/tiny_tds/client.rb#L52), and if the value is true or false, emits a warning inside connect (https://github.com/rails-sqlserver/tiny_tds/blob/master/ext/tiny_tds/client.c#L364-L366).

I think there are a couple options here. You could skip forcing the :use_utf16 value to true if the :use_utf16=>nil option is used, either using Hash#fetch or Hash#has_key? to check if the value is explicitly given as nil, and leave it as nil in that case. Alternatively, maybe just do not warn if the value is false.

metaskills commented 6 years ago

This was intentional because we wanted warn when people had FreeTDS < than v1.0. This was to head off issues with UTF data. I went ahead and changed the message in master for the next version. Information history on the topic below.

jeremyevans commented 6 years ago

Can you switch from rb_warn to rb_warning so it only warns in verbose mode? Alternatively, can you support some other option for people to stop the warning from appearing? For people who rely on the distro's version of FreeTDS and don't have control, it's annoying to get a warning you cannot readily fix, especially for something that will never affect you (none of the databases I connect to are going to care about the UCS-2 vs. UTF-16 difference).

metaskills commented 6 years ago

don't have control cannot readily fix

It has been a few years, I thought the distros would be updated, what version are you on?

especially for something that will never affect you

Not sure that is true. It is very common nowadays to deal with emoji and wide characters in the DB.

Can you switch from rb_warn to rb_warning

Neat idea... let me consider that.

jeremyevans commented 6 years ago

I'm on FreeTDS version 0.95.95, as that's still the default on OpenBSD.

It is very common nowadays to deal with emoji and wide characters in the DB.

Not in the databases I deal with :) I understand the reason behind the warning and agree that UTF-16 is a better default, I'd just like a way to turn the warning off, since for me it is just annoying.

metaskills commented 6 years ago

Thanks for sharing Jeremy. Still torn, in some way, this is a deprecation on 0.95 and deprecations show in non-verbose mode. That said... I'm not seeing a clear reason to deprecate 0.95 now, but its day is coming. I'll change it to rb_warning

metaskills commented 6 years ago

OK, that was changed in master to rb_warning and I am working on release v2.1.2 now. Thanks again @jeremyevans for taking the time to report and talk about these issues.