Skip to content

Commit 5c3e833

Browse files
fix: Address empty field schema in for SDK-based type conforming
See #239 (comment)
1 parent f7bea2b commit 5c3e833

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

tap_postgres/client.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
This includes PostgresStream and PostgresConnector.
44
"""
5+
56
from __future__ import annotations
67

78
import datetime
@@ -123,7 +124,17 @@ def to_jsonschema_type(
123124
type_name = type(sql_type).__name__
124125

125126
if type_name is not None and type_name in ("JSONB", "JSON"):
126-
return {}
127+
return {
128+
"anyOf": [
129+
{"type": "object"},
130+
{"type": "array"},
131+
{"type": "string"},
132+
{"type": "number"},
133+
{"type": "integer"},
134+
{"type": "boolean"},
135+
{"type": "null"},
136+
],
137+
}
127138

128139
if (
129140
type_name is not None

tests/test_core.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,18 @@ def test_jsonb_json():
237237
"stream" in schema_message
238238
and schema_message["stream"] == altered_table_name
239239
):
240-
assert schema_message["schema"]["properties"]["column_jsonb"] == {}
241-
assert schema_message["schema"]["properties"]["column_json"] == {}
240+
props = schema_message["schema"]["properties"]
241+
all_types = [
242+
{"type": "object"},
243+
{"type": "array"},
244+
{"type": "string"},
245+
{"type": "number"},
246+
{"type": "integer"},
247+
{"type": "boolean"},
248+
{"type": "null"},
249+
]
250+
assert props["column_jsonb"]["anyOf"] == all_types
251+
assert props["column_json"]["anyOf"] == all_types
242252
assert test_runner.records[altered_table_name][0] == {
243253
"column_jsonb": {"foo": "bar"},
244254
"column_json": {"baz": "foo"},

0 commit comments

Comments
 (0)