Skip to content

Commit

Permalink
Propagate supportsObjectAutoFlattening in DocumentParserContext (#1…
Browse files Browse the repository at this point in the history
…13711)

* Propagate `supportsObjectAutoFlattening` in DocumentParserContext

* remove noop
  • Loading branch information
kkrik-es authored Sep 27, 2024
1 parent 259b0cd commit 5f66cb8
Showing 1 changed file with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ private DocumentParserContext(
Set<String> fieldsAppliedFromTemplates,
Set<String> copyToFields,
DynamicMapperSize dynamicMapperSize,
boolean recordedSource
boolean recordedSource,
boolean supportsObjectAutoFlattening
) {
this.mappingLookup = mappingLookup;
this.mappingParserContext = mappingParserContext;
Expand All @@ -178,7 +179,7 @@ private DocumentParserContext(
this.copyToFields = copyToFields;
this.dynamicMappersSize = dynamicMapperSize;
this.recordedSource = recordedSource;
this.supportsObjectAutoFlattening = checkForAutoFlatteningSupport();
this.supportsObjectAutoFlattening = supportsObjectAutoFlattening;
}

private DocumentParserContext(ObjectMapper parent, ObjectMapper.Dynamic dynamic, DocumentParserContext in) {
Expand All @@ -202,31 +203,27 @@ private DocumentParserContext(ObjectMapper parent, ObjectMapper.Dynamic dynamic,
in.fieldsAppliedFromTemplates,
in.copyToFields,
in.dynamicMappersSize,
in.recordedSource
in.recordedSource,
in.supportsObjectAutoFlattening
);
}

private boolean checkForAutoFlatteningSupport() {
if (root().subobjects() != ObjectMapper.Subobjects.ENABLED) {
private static boolean checkForAutoFlatteningSupport(MappingLookup mappingLookup, RootObjectMapper rootObjectMapper) {
if (rootObjectMapper.subobjects() != ObjectMapper.Subobjects.ENABLED) {
return true;
}
for (ObjectMapper objectMapper : mappingLookup.objectMappers().values()) {
if (objectMapper.subobjects() != ObjectMapper.Subobjects.ENABLED) {
return true;
}
}
if (root().dynamicTemplates() != null) {
for (DynamicTemplate dynamicTemplate : root().dynamicTemplates()) {
if (rootObjectMapper.dynamicTemplates() != null) {
for (DynamicTemplate dynamicTemplate : rootObjectMapper.dynamicTemplates()) {
if (findSubobjects(dynamicTemplate.getMapping())) {
return true;
}
}
}
for (ObjectMapper objectMapper : dynamicObjectMappers.values()) {
if (objectMapper.subobjects() != ObjectMapper.Subobjects.ENABLED) {
return true;
}
}
return false;
}

Expand Down Expand Up @@ -270,7 +267,8 @@ protected DocumentParserContext(
new HashSet<>(),
new HashSet<>(mappingLookup.fieldTypesLookup().getCopyToDestinationFields()),
new DynamicMapperSize(),
false
false,
checkForAutoFlatteningSupport(mappingLookup, mappingLookup.getMapping().getRoot())
);
}

Expand Down

0 comments on commit 5f66cb8

Please sign in to comment.