Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert can_return_rows_from_bulk_insert to False #336

Merged
merged 5 commits into from
Jan 26, 2024
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
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
Loading