Skip to content

Commit

Permalink
Initialise the schema cache when checking the database version (#1120)
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanharan authored Oct 12, 2023
1 parent 7d35c57 commit 46d304a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/active_record/connection_adapters/sqlserver_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def active?
end

def reconnect
@raw_connection.close rescue nil
@raw_connection&.close rescue nil
@raw_connection = nil
@spid = nil
@collation = nil
Expand All @@ -254,7 +254,7 @@ def reconnect
def disconnect!
super

@raw_connection.close rescue nil
@raw_connection&.close rescue nil
@raw_connection = nil
@spid = nil
@collation = nil
Expand Down Expand Up @@ -338,6 +338,12 @@ def get_database_version # :nodoc:
version_year
end

def check_version # :nodoc:
if schema_cache.database_version < 2012
raise "Your version of SQL Server (#{database_version}) is too old. SQL Server Active Record supports 2012 or higher."
end
end

class << self
protected

Expand Down

0 comments on commit 46d304a

Please sign in to comment.