Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions lib/active_record/connection_adapters/sqlserver_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,10 @@ def initialize(connection, logger, pool, config)
connect
@database_version = select_value 'SELECT @@version', 'SCHEMA'
@database_year = begin
if @database_version =~ /Microsoft SQL Azure/i
if @database_version =~ /Azure/i
@sqlserver_azure = true
@database_version.match(/\s(\d{4})\s/)[1].to_i
@database_version.match(/\s-\s([0-9.]+)/)[1]
year = 2012
else
year = DATABASE_VERSION_REGEXP.match(@database_version)[1]
year == "Denali" ? 2011 : year.to_i
Expand All @@ -218,7 +219,7 @@ def initialize(connection, logger, pool, config)
@edition = select_value "SELECT CAST(SERVERPROPERTY('edition') AS VARCHAR(128))", 'SCHEMA'
initialize_dateformatter
use_database
unless SUPPORTED_VERSIONS.include?(@database_year)
unless (@sqlserver_azure == true || SUPPORTED_VERSIONS.include?(@database_year))
raise NotImplementedError, "Currently, only #{SUPPORTED_VERSIONS.to_sentence} are supported. We got back #{@database_version}."
end
end
Expand Down Expand Up @@ -433,6 +434,7 @@ def connect
client.execute("SET ANSI_PADDING ON").do
client.execute("SET QUOTED_IDENTIFIER ON")
client.execute("SET ANSI_WARNINGS ON").do
client.execute("SET CONCAT_NULL_YIELDS_NULL ON").do
else
client.execute("SET ANSI_DEFAULTS ON").do
client.execute("SET CURSOR_CLOSE_ON_COMMIT OFF").do
Expand Down Expand Up @@ -520,9 +522,10 @@ def auto_reconnected?
@auto_connecting = true
count = 0
while count <= (auto_connect_duration / 2)
sleep 2** count
result = reconnect!
ActiveRecord::Base.did_retry_sqlserver_connection(self,count)
return true if reconnect!
return true if result
sleep 2** count
count += 1
end
ActiveRecord::Base.did_lose_sqlserver_connection(self)
Expand Down