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

Commit 34e9317

Browse files
add docstring
1 parent 93b6a2b commit 34e9317

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

sqeleton/databases/postgresql.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ def normalize_boolean(self, value: str, _coltype: Boolean) -> str:
5050
return self.to_string(f"{value}::int")
5151

5252
def normalize_json(self, value: str, _coltype: PostgresqlJSON) -> str:
53+
"""
54+
Converts json or bjson values to its minified (most compact) string representation.
55+
56+
Removes whitespaces after json separators (':' and ',') using string replacement.
57+
'{"a": 1, "b": true, "c": "x"}' (bjson::text) -> '{"a":1,"b":true,"c":"x"}'
58+
59+
Comparisons to jsons of other db types can give false positives if they contain string
60+
values that include any of the replaced patterns, or if the items have different order.
61+
"""
5362
return f"replace(replace({value}::text, '\": ', '\":'), ', \"', ',\"')"
5463

5564

0 commit comments

Comments
 (0)