@@ -376,7 +376,7 @@ def dblib_connect(config)
376376 TinyTds ::Client . new (
377377 dataserver : config [ :dataserver ] ,
378378 host : config [ :host ] ,
379- port : config [ :port ] ,
379+ port : config_port ( config ) ,
380380 username : config [ :username ] ,
381381 password : config [ :password ] ,
382382 database : config [ :database ] ,
@@ -385,8 +385,10 @@ def dblib_connect(config)
385385 login_timeout : config_login_timeout ( config ) ,
386386 timeout : config_timeout ( config ) ,
387387 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 )
390392 ) . tap do |client |
391393 if config [ :azure ]
392394 client . execute ( 'SET ANSI_NULLS ON' ) . do
@@ -408,6 +410,10 @@ def config_appname(config)
408410 config [ :appname ] || configure_application_name || Rails . application . class . name . split ( '::' ) . first rescue nil
409411 end
410412
413+ def config_port ( config )
414+ config [ :port ] . present? ? config [ :port ] . to_i : nil
415+ end
416+
411417 def config_login_timeout ( config )
412418 config [ :login_timeout ] . present? ? config [ :login_timeout ] . to_i : nil
413419 end
@@ -420,6 +426,22 @@ def config_encoding(config)
420426 config [ :encoding ] . present? ? config [ :encoding ] : nil
421427 end
422428
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+
423445 def configure_connection ; end
424446
425447 def configure_application_name ; end
0 commit comments