Skip to content

Commit e7c257a

Browse files
committed
Proper indent for new TinyTDS client args. Rename config helpers with config_ prefix.
1 parent fee1a2d commit e7c257a

File tree

1 file changed

+33
-41
lines changed

1 file changed

+33
-41
lines changed

lib/active_record/connection_adapters/sqlserver_adapter.rb

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -284,19 +284,19 @@ def connect
284284

285285
def dblib_connect(config)
286286
TinyTds::Client.new(
287-
dataserver: config[:dataserver],
288-
host: config[:host],
289-
port: config[:port],
290-
username: config[:username],
291-
password: config[:password],
292-
database: config[:database],
293-
tds_version: config[:tds_version],
294-
appname: appname(config),
295-
login_timeout: login_timeout(config),
296-
timeout: timeout(config),
297-
encoding: encoding(config),
298-
azure: config[:azure]
299-
).tap do |client|
287+
dataserver: config[:dataserver],
288+
host: config[:host],
289+
port: config[:port],
290+
username: config[:username],
291+
password: config[:password],
292+
database: config[:database],
293+
tds_version: config[:tds_version],
294+
appname: config_appname(config),
295+
login_timeout: config_login_timeout(config),
296+
timeout: config_timeout(config),
297+
encoding: config_encoding(config),
298+
azure: config[:azure]
299+
).tap do |client|
300300
if config[:azure]
301301
client.execute('SET ANSI_NULLS ON').do
302302
client.execute('SET CURSOR_CLOSE_ON_COMMIT OFF').do
@@ -315,22 +315,6 @@ def dblib_connect(config)
315315
end
316316
end
317317

318-
def appname(config)
319-
config[:appname] || configure_application_name || Rails.application.class.name.split('::').first rescue nil
320-
end
321-
322-
def login_timeout(config)
323-
config[:login_timeout].present? ? config[:login_timeout].to_i : nil
324-
end
325-
326-
def timeout(config)
327-
config[:timeout].present? ? config[:timeout].to_i / 1000 : nil
328-
end
329-
330-
def encoding(config)
331-
config[:encoding].present? ? config[:encoding] : nil
332-
end
333-
334318
def odbc_connect(config)
335319
if config[:dsn].include?(';')
336320
driver = ODBC::Driver.new.tap do |d|
@@ -350,19 +334,26 @@ def odbc_connect(config)
350334
end
351335
end
352336

353-
# Override this method so every connection can be configured to your needs.
354-
# For example:
355-
# raw_connection_do "SET TEXTSIZE #{64.megabytes}"
356-
# raw_connection_do "SET CONCAT_NULL_YIELDS_NULL ON"
357-
def configure_connection
337+
def config_appname(config)
338+
config[:appname] || configure_application_name || Rails.application.class.name.split('::').first rescue nil
339+
end
340+
341+
def config_login_timeout(config)
342+
config[:login_timeout].present? ? config[:login_timeout].to_i : nil
358343
end
359344

360-
# Override this method so every connection can have a unique name. Max 30 characters. Used by TinyTDS only.
361-
# For example:
362-
# "myapp_#{$$}_#{Thread.current.object_id}".to(29)
363-
def configure_application_name
345+
def config_timeout(config)
346+
config[:timeout].present? ? config[:timeout].to_i / 1000 : nil
364347
end
365348

349+
def config_encoding(config)
350+
config[:encoding].present? ? config[:encoding] : nil
351+
end
352+
353+
def configure_connection ; end
354+
355+
def configure_application_name ; end
356+
366357
def initialize_dateformatter
367358
@database_dateformat = user_options_dateformat
368359
a, b, c = @database_dateformat.each_char.to_a
@@ -414,6 +405,7 @@ def auto_reconnected?
414405
ensure
415406
@auto_connecting = false
416407
end
417-
end # class SQLServerAdapter < AbstractAdapter
418-
end # module ConnectionAdapters
419-
end # module ActiveRecord
408+
409+
end
410+
end
411+
end

0 commit comments

Comments
 (0)