Fix enum storage in generated schema templates#25
Open
iiegn wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Schema-generated enum fields are not stored in a way that is compatible with backend JSON Schema enum validation.
There are two related problems:
Schema_template_generatorgenerates enum-backed fields without explicitly setting enum storage to the raw enum code.enum_store_columnfor repeatable enum fields.This can cause values like
No [no]to be stored instead ofno, which then fail JSON Schema validation againstenum: ["yes", "no"].Reproduction
{ "type": "string", "enum": ["yes", "no"] }Actual Behavior
Validation fails with an enum error such as:
because the stored value is a display value like
No [no]instead of the schema enum valueno.Repeatable enum fields have the same underlying problem when enum_store_column should be respected.
Expected Behavior
Schema-generated enum fields should store the raw enum code by default, so selecting "No" stores
no, and schema validation passes.Repeatable enum fields should use the same storage rule as single-value enum fields.
Fix
This PR does two things: