Skip to content

Commit 68c105b

Browse files
FIX: Test Exclusions for 5.2 & update README (#469)
* FIX: Test Exclusions for 5.2 & update README * remove duplication Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 8af48ce commit 68c105b

File tree

2 files changed

+125
-6
lines changed

2 files changed

+125
-6
lines changed

README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ We hope you enjoy using the MSSQL-Django 3rd party backend.
1010

1111
## Features
1212

13-
- Supports Django 3.2, 4.0, 4.1, 4.2 and 5.0
13+
- Supports Django 3.2, 4.0, 4.1, 4.2, 5.0, 5.1, and 5.2
14+
- **Django 5.0 and below**: Full production support
15+
- **Django 5.1**: Supported with minor limitations (composite primary key inspectdb)
16+
- **Django 5.2**: Supported with enhanced SQL Server compatibility features and documented limitations (see Django 5.2 Specific Limitations section below)
1417
- Tested on Microsoft SQL Server 2016, 2017, 2019, 2022
1518
- Passes most of the tests of the Django test suite
19+
- Enhanced SQL Server compatibility with automatic schema creation and improved identifier quoting
1620
- Compatible with
1721
[Micosoft ODBC Driver for SQL Server](https://docs.microsoft.com/en-us/sql/connect/odbc/microsoft-odbc-driver-for-sql-server),
1822
[SQL Server Native Client](https://msdn.microsoft.com/en-us/library/ms131321(v=sql.120).aspx),
@@ -273,6 +277,42 @@ The following features are currently not fully supported:
273277
- Date extract function
274278
- Bulk insert into a table with a trigger and returning the rows inserted
275279

280+
### Django 5.1 Specific Limitations
281+
282+
Django 5.1 introduces composite primary key support which has limited compatibility with SQL Server:
283+
- **inspectdb command**: Cannot properly inspect tables with composite primary keys
284+
- **Backend debugging**: SQL execution wrapper debug functionality may not work correctly
285+
- **Schema operations**: Some field unique constraint removal operations may have issues
286+
- Most other Django 5.1 features work correctly with SQL Server
287+
288+
### Django 5.2 Specific Limitations
289+
290+
Django 5.2 introduces new features that may cause regressions for existing Django 5.0+ applications. This release includes enhanced SQL Server compatibility for Django 5.2, with automatic schema creation and improved identifier quoting. The following limitations remain:
291+
292+
**Critical Limitations (May Affect Common Use Cases):**
293+
- **Tuple lookups**: Queries like `Model.objects.filter((col1, col2)__in=[(val1, val2)])` will fail with SQL syntax errors as SQL Server doesn't support `(col1, col2) IN (...)` syntax
294+
- **Multi-column foreign key relationships**: Complex queries involving foreign keys with multiple columns may fail in Django 5.2 due to tuple lookup generation
295+
- **JSONField with special characters**: JSONField lookups involving special characters (quotes, emojis, escape sequences) may generate invalid SQL
296+
- **JSONField bulk updates**: Bulk update operations on JSONField with null handling may fail
297+
298+
**Moderate Impact:**
299+
- **Complex aggregations**: Some aggregation queries with filtered references and subqueries may not work correctly
300+
- **Prefetch operations**: `prefetch_related()` operations on multi-column foreign keys may fail
301+
302+
**Low Impact (Edge Cases):**
303+
- **Migration operations**: Advanced migration operations involving composite primary keys and generated fields
304+
- **Backend debugging**: Certain backend debugging and introspection features
305+
- **JSONField CASE WHEN updates**: JSONField updates using CASE WHEN expressions with null handling
306+
307+
**Specific Test Failures in Django 5.2:**
308+
- All `foreign_object.test_tuple_lookups.TupleLookupsTests.*` tests
309+
- All `foreign_object.tests.MultiColumnFKTests.*` tests involving complex queries
310+
- `model_fields.test_jsonfield.TestQuerying.test_lookups_special_chars*` tests
311+
- `queries.test_bulk_update.BulkUpdateTests.test_json_field_sql_null` test
312+
- Various migration and backend debugging tests
313+
314+
**Workaround**: These limitations are documented in the test exclusions (`testapp/settings.py`) and are excellent candidates for community contributions. Applications using Django 5.0 and below are unaffected by these limitations.
315+
276316
JSONField lookups have limitations, more details [here](https://github.com/microsoft/mssql-django/wiki/JSONField).
277317

278318
## Contributing

testapp/settings.py

Lines changed: 84 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@
9898
USE_TZ = False
9999

100100
TEST_RUNNER = "testapp.runners.ExcludedTestSuiteRunner"
101+
102+
# Test exclusions for features not supported by SQL Server or requiring special handling
103+
# Community contributions welcome to implement these features incrementally
101104
EXCLUDED_TESTS = [
102105
'aggregation_regress.tests.AggregationTests.test_annotation_with_value',
103106
'aggregation.tests.AggregateTestCase.test_distinct_on_aggregate',
@@ -289,13 +292,89 @@
289292
'queries.test_qs_combinators.QuerySetSetOperationTests.test_union_with_select_related_and_order',
290293
'expressions_window.tests.WindowFunctionTests.test_limited_filter',
291294
'schema.tests.SchemaTests.test_remove_ignored_unique_constraint_not_create_fk_index',
292-
293-
# Generated field 5.0.6 tests
294-
'migrations.test_operations.OperationTests.test_invalid_generated_field_changes_on_rename_virtual',
295-
'migrations.test_operations.OperationTests.test_invalid_generated_field_changes_on_rename_stored',
296-
295+
297296
]
298297

298+
# Django 5.0 specific exclusions - these tests fail due to SQL Server limitations
299+
if VERSION >= (5, 0):
300+
EXCLUDED_TESTS.extend([
301+
# Generated field 5.0.6 tests
302+
'migrations.test_operations.OperationTests.test_invalid_generated_field_changes_on_rename_virtual',
303+
'migrations.test_operations.OperationTests.test_invalid_generated_field_changes_on_rename_stored',
304+
])
305+
306+
# Django 5.1 specific exclusions - these tests fail due to SQL Server limitations
307+
if VERSION >= (5, 1):
308+
EXCLUDED_TESTS.extend([
309+
# Composite primary key tests - not supported in SQL Server
310+
'inspectdb.tests.InspectDBTransactionalTests.test_composite_primary_key',
311+
312+
# Backend and schema test failures that appear in Django 5.1
313+
# TODO: Fix SQL Server specific backend behavior
314+
'backends.base.test_base.ExecuteWrapperTests.test_wrapper_debug',
315+
'indexes.tests.SchemaIndexesTests.test_alter_field_unique_false_removes_deferred_sql',
316+
])
317+
318+
# Django 5.2 specific exclusions - tuple lookups not supported in SQL Server
319+
# These are good candidates for community contributions - see GitHub issues
320+
if VERSION >= (5, 2):
321+
EXCLUDED_TESTS.extend([
322+
# Tuple lookup tests - SQL Server doesn't support (col1, col2) IN syntax
323+
# TODO: Implement tuple lookup handling for SQL Server compatibility
324+
'foreign_object.test_tuple_lookups.TupleLookupsTests.test_exact',
325+
'foreign_object.test_tuple_lookups.TupleLookupsTests.test_gt',
326+
'foreign_object.test_tuple_lookups.TupleLookupsTests.test_gte',
327+
'foreign_object.test_tuple_lookups.TupleLookupsTests.test_in',
328+
'foreign_object.test_tuple_lookups.TupleLookupsTests.test_lt',
329+
'foreign_object.test_tuple_lookups.TupleLookupsTests.test_lte',
330+
'foreign_object.test_tuple_lookups.TupleLookupsTests.test_tuple_in_subquery',
331+
'foreign_object.test_agnostic_order_trimjoin.TestLookupQuery.test_deep_mixed_backward',
332+
333+
# inspectdb tests that expect specific table structures in inspectdb_special/pascal schemas
334+
'inspectdb.tests.InspectDBTestCase.test_custom_normalize_table_name',
335+
'inspectdb.tests.InspectDBTestCase.test_special_column_name_introspection',
336+
'inspectdb.tests.InspectDBTestCase.test_table_name_introspection',
337+
338+
# Multi-column foreign key tests with tuple lookups - also affected by SQL Server limitations
339+
# TODO: Fix tuple lookup generation for multi-column FKs
340+
'foreign_object.tests.MultiColumnFKTests.test_double_nested_query',
341+
'foreign_object.tests.MultiColumnFKTests.test_forward_in_lookup_filters_correctly',
342+
'foreign_object.tests.MultiColumnFKTests.test_prefetch_foreignobject_forward',
343+
'foreign_object.tests.MultiColumnFKTests.test_prefetch_foreignobject_hidden_forward',
344+
'foreign_object.tests.MultiColumnFKTests.test_prefetch_foreignobject_reverse',
345+
'foreign_object.tests.MultiColumnFKTests.test_prefetch_related_m2m_forward_works',
346+
'foreign_object.tests.MultiColumnFKTests.test_prefetch_related_m2m_reverse_works',
347+
'foreign_object.tests.MultiColumnFKTests.test_reverse_query_returns_correct_result',
348+
349+
# JSONField special character handling - SQL Server specific syntax issues
350+
# TODO: Fix JSONField key escaping for special characters
351+
'model_fields.test_jsonfield.TestQuerying.test_lookups_special_chars',
352+
'model_fields.test_jsonfield.TestQuerying.test_lookups_special_chars_double_quotes',
353+
354+
# JSONField bulk update with null handling
355+
# TODO: Fix bulk update SQL generation for JSONField null values
356+
'queries.test_bulk_update.BulkUpdateTests.test_json_field_sql_null',
357+
358+
# Migration and composite primary key issues
359+
# TODO: Implement composite primary key support
360+
'migrations.test_operations.OperationTests.test_composite_pk_operations',
361+
'migrations.test_operations.OperationTests.test_generated_field_changes_output_field',
362+
363+
# Backend and schema test failures
364+
# TODO: Fix SQL Server specific backend behavior
365+
# 'backends.base.test_base.ExecuteWrapperTests.test_wrapper_debug', # Removed duplicate; now only in Django 5.2+ block
366+
'indexes.tests.SchemaIndexesTests.test_alter_field_unique_false_removes_deferred_sql',
367+
368+
# Aggregation with filtered references
369+
# TODO: Fix complex aggregation queries with outer references
370+
'aggregation.test_filter_argument.FilteredAggregateTests.test_filtered_aggregrate_ref_in_subquery_annotation',
371+
372+
# JSONField test failures
373+
# TODO: Fix JSONField update with CASE WHEN handling
374+
'expressions.tests.BasicExpressionsTests.test_update_jsonfield_case_when_key_is_null',
375+
376+
])
377+
299378
REGEX_TESTS = [
300379
'lookup.tests.LookupTests.test_regex',
301380
'lookup.tests.LookupTests.test_regex_backreferencing',

0 commit comments

Comments
 (0)