@@ -376,7 +376,7 @@ def dblib_connect(config)
376
376
TinyTds ::Client . new (
377
377
dataserver : config [ :dataserver ] ,
378
378
host : config [ :host ] ,
379
- port : config [ :port ] ,
379
+ port : config_port ( config ) ,
380
380
username : config [ :username ] ,
381
381
password : config [ :password ] ,
382
382
database : config [ :database ] ,
@@ -385,8 +385,10 @@ def dblib_connect(config)
385
385
login_timeout : config_login_timeout ( config ) ,
386
386
timeout : config_timeout ( config ) ,
387
387
encoding : config_encoding ( config ) ,
388
- azure : config [ :azure ] ,
389
- contained : config [ :contained ]
388
+ azure : config_azure ( config ) ,
389
+ contained : config_contained ( config ) ,
390
+ use_utf16 : config_use_utf16 ( config ) ,
391
+ message_handler : config_message_handler ( config )
390
392
) . tap do |client |
391
393
if config [ :azure ]
392
394
client . execute ( 'SET ANSI_NULLS ON' ) . do
@@ -408,6 +410,10 @@ def config_appname(config)
408
410
config [ :appname ] || configure_application_name || Rails . application . class . name . split ( '::' ) . first rescue nil
409
411
end
410
412
413
+ def config_port ( config )
414
+ config [ :port ] . present? ? config [ :port ] . to_i : nil
415
+ end
416
+
411
417
def config_login_timeout ( config )
412
418
config [ :login_timeout ] . present? ? config [ :login_timeout ] . to_i : nil
413
419
end
@@ -420,6 +426,22 @@ def config_encoding(config)
420
426
config [ :encoding ] . present? ? config [ :encoding ] : nil
421
427
end
422
428
429
+ def config_azure ( config )
430
+ config [ :azure ] . present? ? !!ActiveModel ::Type ::Boolean . new . cast ( config [ :azure ] ) : nil
431
+ end
432
+
433
+ def config_contained ( config )
434
+ config [ :contained ] . present? ? !!ActiveModel ::Type ::Boolean . new . cast ( config [ :contained ] ) : nil
435
+ end
436
+
437
+ def config_use_utf16 ( config )
438
+ config [ :use_utf16 ] . present? ? !!ActiveModel ::Type ::Boolean . new . cast ( config [ :use_utf16 ] ) : true
439
+ end
440
+
441
+ def config_message_handler ( config )
442
+ config [ :message_handler ] . present? ? config [ :message_handler ] : nil
443
+ end
444
+
423
445
def configure_connection ; end
424
446
425
447
def configure_application_name ; end
0 commit comments