Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Revert "mssql normalize_uuid" and fix the overall problem #794

Merged
merged 3 commits into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions data_diff/databases/mssql.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
)
from data_diff.abcs.database_types import (
JSON,
ColType_UUID,
NumericType,
Timestamp,
TimestampTZ,
Expand Down Expand Up @@ -120,13 +119,15 @@ def limit_select(
) -> str:
if offset:
raise NotImplementedError("No support for OFFSET in query")

result = ""
if not has_order_by:
result += "ORDER BY 1"

result += f" OFFSET 0 ROWS FETCH NEXT {limit} ROWS ONLY"
return f"SELECT * FROM ({select_query}) AS LIMITED_SELECT {result}"

# mssql requires that subquery columns are all aliased, so
# don't wrap in an outer select
return f"{select_query} {result}"

def constant_values(self, rows) -> str:
values = ", ".join("(%s)" % ", ".join(self._constant_value(v) for v in row) for row in rows)
Expand Down Expand Up @@ -155,9 +156,6 @@ def md5_as_int(self, s: str) -> str:
def md5_as_hex(self, s: str) -> str:
return f"HashBytes('MD5', {s})"

def normalize_uuid(self, value: str, coltype: ColType_UUID) -> str:
return f"TRIM(CAST({value} AS char)) AS {value}"


@attrs.define(frozen=False, init=False, kw_only=True)
class MsSQL(ThreadedDatabase):
Expand Down