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

Filter doesn't support expression as input #4394

Closed
Flowwwww opened this issue May 23, 2023 · 1 comment
Closed

Filter doesn't support expression as input #4394

Flowwwww opened this issue May 23, 2023 · 1 comment
Assignees
Labels
type: bug A general bug

Comments

@Flowwwww
Copy link

Here is the mongo command I want to write using spring data :

  {
    $addFields: {
      _filteredMetadata: {
        $filter: {
          input: {
            $objectToArray: "$data.metadata",
          },
          as: "filteredMetadata",
          cond: {
            $ne: [
              "$$filteredMetadata.k",
              "rawSamplingDate",
            ],
          },
        },
      },
    },
  },
]

Using Spring, i would have done like this :

 addFields()
                        .addField("_filteredMetadata")
                        .withValue(ArrayOperators
                                .arrayOf(ObjectOperators.valueOf("data.metadata").toArray())
                                .filter()
                                .as("filteredMetadata")
                                .by(ComparisonOperators.Ne.valueOf("filteredMetadata.k").notEqualToValue("rawSamplingDate")))
                        .build(),

But filter fails saying :

java.lang.IllegalStateException: Values must not be null
	at org.springframework.util.Assert.state(Assert.java:76)
	at org.springframework.data.mongodb.core.aggregation.ArrayOperators$ArrayOperatorFactory.filter(ArrayOperators.java:217)

It seems Filter input doesn't support expressions 🤔

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 23, 2023
@christophstrobl
Copy link
Member

Thank you @Flowwwww for bringing this up. True, looks like we're missing the expression input path here.

@christophstrobl christophstrobl added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels May 24, 2023
@christophstrobl christophstrobl self-assigned this May 24, 2023
mp911de pushed a commit that referenced this issue Jun 14, 2023
mp911de pushed a commit that referenced this issue Jun 14, 2023
mp911de pushed a commit that referenced this issue Jun 14, 2023
@mp911de mp911de added this to the 3.4.13 (2021.2.13) milestone Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants