Skip to content

Commit 46d304a

Browse files
authored
Initialise the schema cache when checking the database version (#1120)
1 parent 7d35c57 commit 46d304a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/active_record/connection_adapters/sqlserver_adapter.rb

+8-2
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def active?
243243
end
244244

245245
def reconnect
246-
@raw_connection.close rescue nil
246+
@raw_connection&.close rescue nil
247247
@raw_connection = nil
248248
@spid = nil
249249
@collation = nil
@@ -254,7 +254,7 @@ def reconnect
254254
def disconnect!
255255
super
256256

257-
@raw_connection.close rescue nil
257+
@raw_connection&.close rescue nil
258258
@raw_connection = nil
259259
@spid = nil
260260
@collation = nil
@@ -338,6 +338,12 @@ def get_database_version # :nodoc:
338338
version_year
339339
end
340340

341+
def check_version # :nodoc:
342+
if schema_cache.database_version < 2012
343+
raise "Your version of SQL Server (#{database_version}) is too old. SQL Server Active Record supports 2012 or higher."
344+
end
345+
end
346+
341347
class << self
342348
protected
343349

0 commit comments

Comments
 (0)