Skip to content

Commit

Permalink
revert can_return_rows_from_bulk_insert to False (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
mShan0 authored Jan 26, 2024
1 parent 6458503 commit ea3f0a7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion mssql/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions testapp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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},
},
}

Expand Down
9 changes: 5 additions & 4 deletions testapp/tests/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit ea3f0a7

Please sign in to comment.