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

Commit f7c1b9d

Browse files
author
Sergey Vasilyev
committed
Eliminate unused specification of JSON column types
1 parent f9bf8a7 commit f7c1b9d

File tree

3 files changed

+8
-24
lines changed

3 files changed

+8
-24
lines changed

data_diff/sqeleton/abcs/database_types.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,6 @@ class JSON(ColType):
138138
pass
139139

140140

141-
class RedShiftSuper(JSON):
142-
pass
143-
144-
145-
class PostgresqlJSON(JSON):
146-
pass
147-
148-
149-
class PostgresqlJSONB(JSON):
150-
pass
151-
152-
153141
@dataclass
154142
class Integer(NumericType, IKey):
155143
precision: int = 0

data_diff/sqeleton/databases/postgresql.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from ..abcs.database_types import (
22
DbPath,
3+
JSON,
34
Timestamp,
45
TimestampTZ,
56
Float,
@@ -11,8 +12,6 @@
1112
FractionalType,
1213
Boolean,
1314
Date,
14-
PostgresqlJSON,
15-
PostgresqlJSONB
1615
)
1716
from ..abcs.mixins import AbstractMixin_MD5, AbstractMixin_NormalizeValue
1817
from .base import BaseDialect, ThreadedDatabase, import_helper, ConnectError, Mixin_Schema
@@ -51,7 +50,7 @@ def normalize_number(self, value: str, coltype: FractionalType) -> str:
5150
def normalize_boolean(self, value: str, _coltype: Boolean) -> str:
5251
return self.to_string(f"{value}::int")
5352

54-
def normalize_json(self, value: str, _coltype: PostgresqlJSON) -> str:
53+
def normalize_json(self, value: str, _coltype: JSON) -> str:
5554
return f"{value}::text"
5655

5756

@@ -81,12 +80,10 @@ class PostgresqlDialect(BaseDialect, Mixin_Schema):
8180
"character varying": Text,
8281
"varchar": Text,
8382
"text": Text,
84-
# JSON
85-
"json": PostgresqlJSON,
86-
"jsonb": PostgresqlJSONB,
87-
# UUID
83+
84+
"json": JSON,
85+
"jsonb": JSON,
8886
"uuid": Native_UUID,
89-
# Boolean
9087
"boolean": Boolean,
9188
}
9289

data_diff/sqeleton/databases/redshift.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from typing import List, Dict
22
from ..abcs.database_types import (
33
Float,
4+
JSON,
45
TemporalType,
56
FractionalType,
67
DbPath,
78
TimestampTZ,
8-
RedShiftSuper
99
)
1010
from ..abcs.mixins import AbstractMixin_MD5
1111
from .postgresql import (
@@ -47,7 +47,7 @@ def normalize_timestamp(self, value: str, coltype: TemporalType) -> str:
4747
def normalize_number(self, value: str, coltype: FractionalType) -> str:
4848
return self.to_string(f"{value}::decimal(38,{coltype.precision})")
4949

50-
def normalize_json(self, value: str, _coltype: RedShiftSuper) -> str:
50+
def normalize_json(self, value: str, _coltype: JSON) -> str:
5151
return f'nvl2({value}, json_serialize({value}), NULL)'
5252

5353

@@ -57,8 +57,7 @@ class Dialect(PostgresqlDialect):
5757
**PostgresqlDialect.TYPE_CLASSES,
5858
"double": Float,
5959
"real": Float,
60-
# JSON
61-
"super": RedShiftSuper
60+
"super": JSON,
6261
}
6362
SUPPORTS_INDEXES = False
6463

0 commit comments

Comments
 (0)