Skip to content

fix: MsSQL timezone-safe timestamp normalization via AT TIME ZONE #30

@dtsong

Description

@dtsong

Problem

MsSQL cannot set a session timezone (mssql.py:85 raises NotImplementedError). When comparing MsSQL timestamps against a UTC-normalized database (e.g., PostgreSQL), phantom diffs appear for any timestamps where the MsSQL server timezone differs from UTC.

Solution

MsSQL supports AT TIME ZONE 'UTC' syntax. Wrap timestamp normalization in normalize_timestamp() to explicitly convert to UTC, bypassing the need for a session-level setting.

Key Files

  • data_diff/databases/mssql.py:85 (set_timezone_to_utc)
  • data_diff/databases/mssql.py (normalize_timestamp)

Acceptance Criteria

  • normalize_timestamp() wraps values with AT TIME ZONE 'UTC' conversion
  • Cross-database diff between MsSQL and PostgreSQL produces correct results regardless of MsSQL server timezone
  • Unit test covers the SQL generation

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0-criticalShip-blocking, fix immediatelybugSomething isn't workingtriage

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions