Skip to content

Commit 8b6f2a9

Browse files
committed
fix issue #9
1 parent bf58f97 commit 8b6f2a9

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

django_pyodbc/creation.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,20 @@ class DatabaseCreation(BaseDatabaseCreation):
5252
def _destroy_test_db(self, test_database_name, verbosity):
5353
"Internal implementation - remove the test db tables."
5454
cursor = self.connection.cursor()
55-
self.set_autocommit()
55+
self.connection.connection.autocommit = True
5656
#time.sleep(1) # To avoid "database is being accessed by other users" errors.
5757
cursor.execute("ALTER DATABASE %s SET SINGLE_USER WITH ROLLBACK IMMEDIATE " % \
5858
self.connection.ops.quote_name(test_database_name))
5959
cursor.execute("DROP DATABASE %s" % \
6060
self.connection.ops.quote_name(test_database_name))
6161
self.connection.close()
62+
63+
def _prepare_for_test_db_ddl(self):
64+
self.connection.connection.rollback()
65+
self.connection.connection.autocommit = True
66+
67+
def sql_table_creation_suffix(self):
68+
suffix = []
69+
if self.connection.settings_dict['TEST_COLLATION']:
70+
suffix.append('COLLATE %s' % self.connection.settings_dict['TEST_COLLATION'])
71+
return ' '.join(suffix)

django_pyodbc/operations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ def sql_flush(self, style, tables, sequences):
179179
if tables:
180180
# Cannot use TRUNCATE on tables that are referenced by a FOREIGN KEY
181181
# So must use the much slower DELETE
182-
from django.db import connection
183-
cursor = connection.cursor()
182+
from django.db import connections
183+
cursor = connections[self.connection.alias].cursor()
184184
# Try to minimize the risks of the braindeaded inconsistency in
185185
# DBCC CHEKIDENT(table, RESEED, n) behavior.
186186
seqs = []

0 commit comments

Comments
 (0)