ReleaseMicrosoftMicrosoftpublished May 22, 2026seen 1w

microsoft/mssql-django 1.7.2

microsoft/mssql-django

Open original ↗

Captured source

source ↗
published May 22, 2026seen 1wcaptured 1whttp 200method plain

1.7.2

Repository: microsoft/mssql-django

Tag: 1.7.2

Published: 2026-05-22T12:22:06Z

Prerelease: no

Release notes:

mssql-django 1.7.2 Release Notes (May 2026)

mssql-django 1.7.2 is a patch release that fixes timezone handling bugs and resolves a Django 4.0+ compatibility issue with .explain().

---

Bug Fixes

FIX: AttributeError on .explain() for Django 4.0+ (#409, #524)

  • What changed: Django 4.0 replaced query.explain_format and query.explain_options with a single query.explain_info namedtuple. The compiler was still referencing the removed attributes, causing an AttributeError when .explain() was called (e.g., via DjangoQL in Django admin). The compiler now version-gates the attribute access: explain_info.format/.options on Django 4.0+, falling back to the old attributes on earlier versions. A regression test was added.
  • Who benefits: Anyone using .explain() or tools like DjangoQL on Django 4.0+
  • Impact: .explain() now correctly raises NotSupportedError instead of crashing with AttributeError

FIX: DATETIMEOFFSET timezone support and Now() with USE_TZ=True (#484, closes #371, closes #136)

  • What changed: Two related timezone bugs were fixed:

1. handle_datetimeoffset was discarding the timezone offset bytes returned by SQL Server, returning naive datetimes from DATETIMEOFFSET columns. The function now parses the full 9-element struct (including tz_offset_hour and tz_offset_minute) and returns timezone-aware datetimes. This completes the original fix from PR #140 which accidentally dropped the offset parsing. 2. sqlserver_now() always emitted SYSDATETIME(), which returns server-local time without an offset. When USE_TZ=True and the SQL Server host was not in UTC, Django would misinterpret the local time as UTC, causing timestamps to shift. Now() now emits SYSDATETIMEOFFSET() when settings.USE_TZ=True, and SYSDATETIME() otherwise.

  • Who benefits: Applications using USE_TZ=True on non-UTC SQL Server hosts, and anyone with DATETIMEOFFSET columns
  • Impact: auto_now, auto_now_add, and Now() annotations now produce correct timestamps. DATETIMEOFFSET columns return timezone-aware datetimes as intended.

---

Test Improvements

  • Removed return in finally that swallowed exceptions in test utility (#526, closes #417)
  • Added timezone offset tests: UTC, +05:30 (IST), -05:00 (EST), -09:30 (Marquesas), +05:45 (Nepal)
  • Added NowSQLTemplateTests verifying SYSDATETIMEOFFSET vs SYSDATETIME based on USE_TZ
  • Added ExplainRegressionTests for .explain() behavior

---

Version Compatibility

| Component | Supported Versions | |---|---| | Django | 3.2, 4.0, 4.1, 4.2, 5.0, 5.1, 5.2, 6.0 | | Python | 3.8 – 3.14 | | SQL Server | 2016, 2017, 2019, 2022, 2025; Azure SQL DB / Managed Instance / Microsoft Fabric | | ODBC Driver | 17 or 18 for SQL Server (v18 is the default) |

---

Breaking Changes

None. This is a fully backward-compatible patch release. The DATETIMEOFFSET fix only affects the USE_TZ=True code path where Django already expects timezone-aware datetimes.

---

Contributors

Thank you to everyone who contributed to this release!

Community Contributors:

  • @trolldbois (Loïc Jaquemet) — DATETIMEOFFSET timezone support and Now() fix (#484)

---

Full Changelog

PRs included: #524, #484, #526

Notability

notability 3.0/10

Minor patch release for Django SQL Server backend.