In Compass we are providing the feature to allow users to generate code from the aggregation pipelines they've configured - including Java code.
With the change introduced by JAVA-3338, the code now generates invalid code as we were using and(...) to generate a BSON document.
The code generation takes a BSON document as an input (noted down in valid JavaScript) and transforms it into idiomatic Java using the fluid API. However, the main piece we are lacking from the fluid API now is to create a "flattened" document out of other fluid API calls.
Example input BSON document:
{
x: "1",
y: 42
}
Previously generated output:
and( eq("x", "1"), eq("y", 42) )
Which now leads to the (wrong) BSON:
{
$and: [{ x: "1" }, { y: 42 }]
}
We would love to have a fluid method like doc(...) or flatten(...) that would allow to generate the following Java code:
flatten( eq("x", "1"), eq("y", 42) )
And produces the above mentioned input BSON document as result. The semantics regarding overlapping field properties would be that a later flattened document overrides a previous property.
See COMPASS-4475 and https://mongodb.slack.com/archives/C0V5KNS3X/p1611234779003900 for more context.
- is depended on by
-
COMPASS-4475 Aggregation tool generating Java code that causes runtime errors
- Closed