Skip to content

Commit f216e3d

Browse files
vijay-koppalametaskills
authored andcommitted
Don't reset use_utf16 option, when initializing with false (#314)
* Don't reset use_utf16 option, when tried to initialize with false ||= is a deceiving operator for Boolean values. It could mean assign-if-nil or assign-if-false. It is just a short-hand for `a = a || new_value` * Considered non-existence option as true * Initialized "use_utf16" Ruby Symbol Object
1 parent 1bdd13c commit f216e3d

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

ext/tiny_tds/client.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ void init_tinytds_client() {
409409
sym_encoding = ID2SYM(rb_intern("encoding"));
410410
sym_azure = ID2SYM(rb_intern("azure"));
411411
sym_contained = ID2SYM(rb_intern("contained"));
412+
sym_use_utf16 = ID2SYM(rb_intern("use_utf16"));
412413
/* Intern TinyTds::Error Accessors */
413414
intern_source_eql = rb_intern("source=");
414415
intern_severity_eql = rb_intern("severity=");

lib/tiny_tds/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def initialize(opts = {})
4242
opts[:password] = opts[:password].to_s if opts[:password] && opts[:password].to_s.strip != ''
4343
opts[:appname] ||= 'TinyTds'
4444
opts[:tds_version] = tds_versions_setter(opts)
45-
opts[:use_utf16] ||= true
45+
opts[:use_utf16] = opts[:use_utf16].nil? || ["true", "1", "yes"].include?(opts[:use_utf16].to_s)
4646
opts[:login_timeout] ||= 60
4747
opts[:timeout] ||= 5
4848
opts[:encoding] = opts[:encoding].nil? || opts[:encoding].casecmp('utf8').zero? ? 'UTF-8' : opts[:encoding].upcase

0 commit comments

Comments
 (0)