Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix nullable enum fields #217

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -259,19 +259,22 @@ public Object toConnect(final Schema schema,
final JsonNode value,
final JsonSchemaDataConfig jsonSchemaDataConfig) {
jsonNodeToConnectValueConverter = new JsonNodeToConnectValueConverter(jsonSchemaDataConfig);
Object converted = null;
Struct converted = null;
if (schema.name() != null && schema.name()
.equals(JsonSchemaConverterConstants.JSON_SCHEMA_TYPE_ONEOF)) {
// Special case support for union types
for (Field field : schema.fields()) {
Schema fieldSchema = field.schema();

if (isInstanceOfJsonSchemaTypeForSimpleSchema(fieldSchema, value) || structSchemaEquals(fieldSchema,
value)) {
converted = new Struct(schema.schema()).put("field" + (field.index() + 1),
jsonNodeToConnectValueConverter.toConnectValue(
fieldSchema, value));
break;
value)) {
if (converted == null) {
converted = new Struct(schema.schema());
}
converted.put("field" + (field.index() + 1),
jsonNodeToConnectValueConverter.toConnectValue(
fieldSchema, value));

}
}
if (converted == null) {
Expand Down