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
21 changes: 6 additions & 15 deletions lib/active_record/connection_adapters/sqlserver_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class SQLServerAdapter < AbstractAdapter
DATABASE_VERSION_REGEXP = /Microsoft SQL Server\s+"?(\d{4}|\w+)"?/
SUPPORTED_VERSIONS = [2005,2008,2010,2011].freeze

attr_reader :database_version, :database_year, :spid
attr_reader :database_version, :database_year, :spid, :product_level, :product_version, :edition

cattr_accessor :native_text_database_type, :native_binary_database_type, :native_string_database_type,
:log_info_schema_queries, :enable_default_unicode_types, :auto_connect,
Expand Down Expand Up @@ -208,6 +208,9 @@ def initialize(logger,config)
rescue
0
end
@product_level = info_schema_query { select_value("SELECT CAST(SERVERPROPERTY('productlevel') AS VARCHAR(128))") }
@product_version = info_schema_query { select_value("SELECT CAST(SERVERPROPERTY('productversion') AS VARCHAR(128))") }
@edition = info_schema_query { select_value("SELECT CAST(SERVERPROPERTY('edition') AS VARCHAR(128))") }
initialize_dateformatter
initialize_sqlserver_caches
use_database
Expand Down Expand Up @@ -323,20 +326,8 @@ def version
self.class::VERSION
end

def product_level
@product_level ||= info_schema_query { select_value("SELECT CAST(SERVERPROPERTY('productlevel') AS VARCHAR(128))")}
end

def product_version
@product_version ||= info_schema_query { select_value("SELECT CAST(SERVERPROPERTY('productversion') AS VARCHAR(128))")}
end

def edition
@edition ||= info_schema_query { select_value("SELECT CAST(SERVERPROPERTY('edition') AS VARCHAR(128))")}
end

def inspect
"#<#{self.class} version: #{version}, year: #{@database_year}, product_level: #{product_level.inspect}, product_version: #{product_version.inspect}, edition: #{edition.inspect}, connection_options: #{@connection_options.inspect}>"
"#<#{self.class} version: #{version}, year: #{@database_year}, product_level: #{@product_level.inspect}, product_version: #{@product_version.inspect}, edition: #{@edition.inspect}, connection_options: #{@connection_options.inspect}>"
end

def auto_connect
Expand Down Expand Up @@ -443,7 +434,7 @@ def connect
end
end
end
@spid = _raw_select("SELECT @@SPID", :fetch => :rows).first.first
@spid = _raw_select("SELECT @@SPID", :fetch => :rows).first.first
configure_connection
rescue
raise unless @auto_connecting
Expand Down