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

AggregationExpression rendering does not consider nested property aliasing [DATAMONGO-1871] #2773

spring-projects-issues opened this issue Feb 12, 2018 · 1 comment


Copy link

@spring-projects-issues spring-projects-issues commented Feb 12, 2018

David Billings opened DATAMONGO-1871 and commented

I've encountered this issue when using a filter inside a projection. When using an AggregationOperationContext and calling .as I used a . in the alias to indicate the result should be nested under another object. This works perfectly in MongoDB but Spring Data MongoDB strips everything leaving just the end field name and thus the nesting is ignored.

Code below (Note this is Kotlin)

 project("_id", "dId", "aId", "cty", "cat", "plts.plt").and {
                    val format = SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH)
                    val filterExpression = BasicDBObject();
                    filterExpression["input"] = "\$plts.ests"
                    filterExpression["as"] = "est"
                    filterExpression["cond"] = BasicDBObject("\$and", listOf(
                            BasicDBObject("\$gte", listOf("\$\$est.dt", format.parse("2015-12-29"))),
                                    BasicDBObject("\$lte", listOf("\$\$est.dt", format.parse("2017-01-29")))))

                    Document("\$filter", filterExpression)

Would result in the projection just being at the root of the document under a field called "ests"

Affects: 2.0.3 (Kay SR3)

Referenced from: pull request #533, and commits 6a20ddf, 0edaf87, 7275a10, 5a783ba, 2ac3814, cec6526, 498f9bd, 2be2cc8, d48dbc5

Backported to: 2.0.4 (Kay SR4), 1.10.11 (Ingalls SR11)

Copy link

@spring-projects-issues spring-projects-issues commented Feb 13, 2018

Christoph Strobl commented

thanks David Billings for reporting.
There's already a snapshot (2.1.0.DATAMONGO-1871-SNAPSHOT) with a fix available via if you want to give it a try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants