Skip to content

Commit 7ac47d9

Browse files
fix: Address empty field schema in for SDK-based type conforming
See #239 (comment)
1 parent 28c9b64 commit 7ac47d9

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

tap_postgres/client.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,17 @@ def to_jsonschema_type(
125125
type_name = type(sql_type).__name__
126126

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

130140
if (
131141
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)