Skip to content

Commit 403eae4

Browse files
committed
fix bug where columnType mistaken conflicts with no type validaiton rules
1 parent aecb158 commit 403eae4

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

schematic/schemas/create_json_schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ def _get_validation_rule_based_fields(
281281
# Schematic will use the implicit type if the explicit type isn't specified for now,
282282
# but this behavior is deprecated and will be removed in the future by SCHEMATIC-326
283283
implicit_js_type = get_js_type_from_inputted_rules(validation_rules)
284-
# If there is an explicit type set...
285-
if explicit_js_type:
284+
# If there is an explicit and implicit type set...
285+
if explicit_js_type and implicit_js_type:
286286
# and the implicit type conflicts with the explicit type, then an exception is raised
287287
if explicit_js_type != implicit_js_type:
288288
msg = (

tests/unit/test_create_json_schema.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,16 @@ def test_get_validation_rule_based_fields_no_explicit_type(
283283
None,
284284
None,
285285
),
286+
(
287+
["list"],
288+
JSONSchemaType.STRING,
289+
JSONSchemaType.STRING,
290+
True,
291+
None,
292+
None,
293+
None,
294+
None,
295+
),
286296
(
287297
["inRange 50 100"],
288298
JSONSchemaType.NUMBER,
@@ -324,7 +334,7 @@ def test_get_validation_rule_based_fields_no_explicit_type(
324334
JSONSchemaFormat.URI,
325335
),
326336
],
327-
ids=["No rules", "String", "InRange", "Regex", "Date", "URL"],
337+
ids=["No rules", "String", "List string", "InRange", "Regex", "Date", "URL"],
328338
)
329339
def test_get_validation_rule_based_fields_with_explicit_type(
330340
validation_rules: list[str],

0 commit comments

Comments
 (0)