Skip to content

Commit b427b4d

Browse files
committed
fix for quote_name
1 parent c4d87b8 commit b427b4d

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

mssql/operations.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,21 @@ def quote_name(self, name):
380380
"""
381381
if name.startswith('[') and name.endswith(']'):
382382
return name # Quoting once is enough.
383+
384+
# Handle schema.table names properly
385+
if '.' in name and not (name.startswith('[') and name.endswith(']')):
386+
parts = name.split('.')
387+
if len(parts) == 2:
388+
schema, table = parts
389+
# Only split if both parts are meaningful (not empty)
390+
if schema and table:
391+
# Quote each part separately if they aren't already quoted
392+
if not (schema.startswith('[') and schema.endswith(']')):
393+
schema = '[%s]' % schema
394+
if not (table.startswith('[') and table.endswith(']')):
395+
table = '[%s]' % table
396+
return '%s.%s' % (schema, table)
397+
383398
return '[%s]' % name
384399

385400
def random_function_sql(self):

testapp/settings.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,11 @@
330330
'foreign_object.test_tuple_lookups.TupleLookupsTests.test_tuple_in_subquery',
331331
'foreign_object.test_agnostic_order_trimjoin.TestLookupQuery.test_deep_mixed_backward',
332332

333-
# Migration data persistence - exclude entire module due to table name with spaces issue
334-
'migration_test_data_persistence',
335-
'migration_test_data_persistence.tests',
336-
'migration_test_data_persistence.tests.MigrationDataPersistenceClassSetup',
333+
# Migration data persistence tests - FIXED: table name with spaces issue resolved
334+
# Fixed by improving quote_name method to handle schema.table names properly
335+
# 'migration_test_data_persistence.tests.MigrationDataPersistenceTestCase.test_persistence',
336+
# 'migration_test_data_persistence.tests.MigrationDataPersistenceClassSetup.test_data_available_in_class_setup',
337+
# 'migration_test_data_persistence.tests.MigrationDataNormalPersistenceTestCase.test_persistence',
337338

338339
# Multi-column foreign key tests with tuple lookups - also affected by SQL Server limitations
339340
# TODO: Fix tuple lookup generation for multi-column FKs

0 commit comments

Comments
 (0)