Open
Description
Zsombor opened DATAMONGO-2637 and commented
We use a couple of projections in our app to limit the amount of data to transfer, with something like this:
aggregationSteps += Aggregation.project(
"aaaa",
"bbbb",
"cccc",
"dddd"
.... (20 more similar lines)
However, in a refactor, we moved a couple of fields into a sub-entity, and blindly adjusted the projection to this:
aggregationSteps += Aggregation.project(
"aaaa",
"bbbb",
"xxx.cccc",
"dddd"
... (20 more similar lines)
Which surprisingly doesn't work as expected.
The smallest solution, which I could find is:
val fields = listOf(
"aaaa",
"bbbb",
"xxx.cccc",
"dddd"
... (20 more similar lines)
).map { Fields.field(it, it) }
aggregationSteps += Aggregation.project(Fields.from(*fields.toTypedArray()))
So the issue is:
- Aggregation.project(
String... names)and Fields.fields(
String... names) has a surprising default behavior - There is no API which takes an array of strings, or a list of strings as field names for projections
- There is no API which takes a list of Fields for projections
Affects: 3.0.4 (Neumann SR4)