Skip to content

Commit

Permalink
Avoid using dynamic:strict with subobjects:false at root (elastic…
Browse files Browse the repository at this point in the history
  • Loading branch information
kkrik-es authored Oct 7, 2024
1 parent a83046a commit 9cfe679
Showing 1 changed file with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,22 @@ public DataSourceResponse.ObjectMappingParametersGenerator handle(DataSourceRequ
return new DataSourceResponse.ObjectMappingParametersGenerator(() -> {
var parameters = new HashMap<String, Object>();

if (request.parentSubobjects() == ObjectMapper.Subobjects.DISABLED) {
// Changing subobjects from subobjects: false is not supported, but we can f.e. go from "true" to "false".
// TODO enable subobjects: auto
// It is disabled because it currently does not have auto flattening and that results in asserts being triggered when using
// copy_to.
if (ESTestCase.randomBoolean()) {
parameters.put(
"subobjects",
ESTestCase.randomValueOtherThan(
ObjectMapper.Subobjects.AUTO,
() -> ESTestCase.randomFrom(ObjectMapper.Subobjects.values())
).toString()
);
}

if (request.parentSubobjects() == ObjectMapper.Subobjects.DISABLED
|| parameters.getOrDefault("subobjects", "true").equals("false")) {
// "enabled: false" is not compatible with subobjects: false
// changing "dynamic" from parent context is not compatible with subobjects: false
// changing subobjects value is not compatible with subobjects: false
Expand All @@ -115,19 +130,6 @@ public DataSourceResponse.ObjectMappingParametersGenerator handle(DataSourceRequ
if (ESTestCase.randomBoolean()) {
parameters.put("enabled", ESTestCase.randomFrom("true", "false"));
}
// Changing subobjects from subobjects: false is not supported, but we can f.e. go from "true" to "false".
// TODO enable subobjects: auto
// It is disabled because it currently does not have auto flattening and that results in asserts being triggered when using
// copy_to.
if (ESTestCase.randomBoolean()) {
parameters.put(
"subobjects",
ESTestCase.randomValueOtherThan(
ObjectMapper.Subobjects.AUTO,
() -> ESTestCase.randomFrom(ObjectMapper.Subobjects.values())
).toString()
);
}

if (ESTestCase.randomBoolean()) {
var value = request.isRoot() ? ESTestCase.randomFrom("none", "arrays") : ESTestCase.randomFrom("none", "arrays", "all");
Expand Down

0 comments on commit 9cfe679

Please sign in to comment.