From ea3f0a78079ba9f6fc35f4ad14c0fe730aff2dbc Mon Sep 17 00:00:00 2001 From: mShan0 <96149598+mShan0@users.noreply.github.com> Date: Fri, 26 Jan 2024 09:53:21 -0800 Subject: [PATCH] revert can_return_rows_from_bulk_insert to False (#336) --- mssql/features.py | 2 +- testapp/settings.py | 4 ++-- testapp/tests/test_queries.py | 9 +++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/mssql/features.py b/mssql/features.py index bca20cac..b85ecf36 100644 --- a/mssql/features.py +++ b/mssql/features.py @@ -13,7 +13,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): can_introspect_small_integer_field = True can_return_columns_from_insert = True can_return_id_from_insert = True - can_return_rows_from_bulk_insert = True + can_return_rows_from_bulk_insert = False can_rollback_ddl = True can_use_chunked_reads = False for_update_after_from = True diff --git a/testapp/settings.py b/testapp/settings.py index f6a19593..fa8a4e26 100644 --- a/testapp/settings.py +++ b/testapp/settings.py @@ -15,7 +15,7 @@ "PASSWORD": "MyPassword42", "HOST": "localhost", "PORT": "1433", - "OPTIONS": {"driver": "ODBC Driver 17 for SQL Server", }, + "OPTIONS": {"driver": "ODBC Driver 17 for SQL Server", "return_rows_bulk_insert": True}, }, 'other': { "ENGINE": "mssql", @@ -24,7 +24,7 @@ "PASSWORD": "MyPassword42", "HOST": "localhost", "PORT": "1433", - "OPTIONS": {"driver": "ODBC Driver 17 for SQL Server", }, + "OPTIONS": {"driver": "ODBC Driver 17 for SQL Server", "return_rows_bulk_insert": True}, }, } diff --git a/testapp/tests/test_queries.py b/testapp/tests/test_queries.py index 1f182d7d..785db023 100644 --- a/testapp/tests/test_queries.py +++ b/testapp/tests/test_queries.py @@ -7,10 +7,6 @@ class TestTableWithTrigger(TransactionTestCase): def test_insert_into_table_with_trigger(self): connection = connections['default'] - # Change can_return_rows_from_bulk_insert to be the same as when - # has_trigger = True - connection.features_class.can_return_rows_from_bulk_insert = False - with connection.schema_editor() as cursor: cursor.execute(""" CREATE TRIGGER TestTrigger @@ -21,9 +17,14 @@ def test_insert_into_table_with_trigger(self): """) try: + # Change can_return_rows_from_bulk_insert to be the same as when + # has_trigger = True + old_return_rows_flag = connection.features_class.can_return_rows_from_bulk_insert + connection.features_class.can_return_rows_from_bulk_insert = False Author.objects.create(name='Foo') except django.db.utils.ProgrammingError as e: self.fail('Check for regression of issue #130. Insert with trigger failed with exception: %s' % e) finally: with connection.schema_editor() as cursor: cursor.execute("DROP TRIGGER TestTrigger") + connection.features_class.can_return_rows_from_bulk_insert = old_return_rows_flag \ No newline at end of file