Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def exec_update(sql, name, binds)
end

def begin_db_transaction
do_execute "BEGIN TRANSACTION"
do_execute "BEGIN TRANSACTION", "TRANSACTION"
end

def transaction_isolation_levels
Expand All @@ -67,25 +67,25 @@ def begin_isolated_db_transaction(isolation)
end

def set_transaction_isolation_level(isolation_level)
do_execute "SET TRANSACTION ISOLATION LEVEL #{isolation_level}"
do_execute "SET TRANSACTION ISOLATION LEVEL #{isolation_level}", "TRANSACTION"
end

def commit_db_transaction
do_execute "COMMIT TRANSACTION"
do_execute "COMMIT TRANSACTION", "TRANSACTION"
end

def exec_rollback_db_transaction
do_execute "IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION"
do_execute "IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION", "TRANSACTION"
end

include Savepoints

def create_savepoint(name = current_savepoint_name)
do_execute "SAVE TRANSACTION #{name}"
do_execute "SAVE TRANSACTION #{name}", "TRANSACTION"
end

def exec_rollback_to_savepoint(name = current_savepoint_name)
do_execute "ROLLBACK TRANSACTION #{name}"
do_execute "ROLLBACK TRANSACTION #{name}", "TRANSACTION"
end

def release_savepoint(name = current_savepoint_name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ module SQLServer
class SchemaCreation < SchemaCreation
private

def supports_index_using?
false
end

def visit_TableDefinition(o)
if_not_exists = o.if_not_exists

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def drop_table(table_name, **options)
end
end
if options[:if_exists] && @version_year < 2016
execute "IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = #{quote(table_name)}) DROP TABLE #{quote_table_name(table_name)}"
execute "IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = #{quote(table_name)}) DROP TABLE #{quote_table_name(table_name)}", "SCHEMA"
else
super
end
Expand Down
26 changes: 14 additions & 12 deletions test/support/sql_counter_sqlserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@ def capture_sql_ss
end
end

ignored_sql = [
/INFORMATION_SCHEMA\.(TABLES|VIEWS|COLUMNS|KEY_COLUMN_USAGE)/im,
/sys.columns/i,
/SELECT @@version/,
/SELECT @@TRANCOUNT/,
/(BEGIN|COMMIT|ROLLBACK|SAVE) TRANSACTION/,
/SELECT CAST\(.* AS .*\) AS value/,
/SELECT DATABASEPROPERTYEX/im
]

sqlcounter = ObjectSpace.each_object(ActiveRecord::SQLCounter).to_a.first
sqlcounter.instance_variable_set :@ignore, Regexp.union(ignored_sql.push(sqlcounter.ignore))
# TODO: Delete the code below after all Rails 6.1 tests passing.
#
# ignored_sql = [
# /INFORMATION_SCHEMA\.(TABLES|VIEWS|COLUMNS|KEY_COLUMN_USAGE)/im,
# /sys.columns/i,
# /SELECT @@version/,
# /SELECT @@TRANCOUNT/,
# /(BEGIN|COMMIT|ROLLBACK|SAVE) TRANSACTION/,
# /SELECT CAST\(.* AS .*\) AS value/,
# /SELECT DATABASEPROPERTYEX/im
# ]
#
# sqlcounter = ObjectSpace.each_object(ActiveRecord::SQLCounter).to_a.first
# sqlcounter.instance_variable_set :@ignore, Regexp.union(ignored_sql.push(sqlcounter.ignore))
end
end