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

Need More Enhancement and Updation on SpEl - MethodReferenceNode.class #4872

Open
ganeshbabugb opened this issue Jan 13, 2025 · 2 comments
Open
Assignees
Labels
status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged

Comments

@ganeshbabugb
Copy link

ganeshbabugb commented Jan 13, 2025

Hey Team, This is Ganesh. I feel that the available operations In SpEl - MethodReferenceNode work's fine but, In some operations like $trunc it doesn't works expected. when i give second argument it doesn't work well. Thank You.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 13, 2025
@mp911de
Copy link
Member

mp911de commented Jan 14, 2025

If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal yet complete sample that reproduces the problem.
You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

@mp911de mp911de added the status: waiting-for-feedback We need additional information before we can continue label Jan 14, 2025
@ganeshbabugb
Copy link
Author

ganeshbabugb commented Jan 14, 2025

This is the simple example which help's you to reproduce this issue.

Ref: https://www.mongodb.com/docs/manual/reference/operator/aggregation/trunc/

@Component
@RequiredArgsConstructor
public class DemoService {
    private final MongoTemplate mongoTemplate;

    @EventListener({ApplicationStartedEvent.class})
    public void demoFunc() {
        // Initial Test Doc, Saved to DB Collection.
	//mongoTemplate.save(Map.of("test-key", 99.9999), "test-collection");

        // Actual Aggregation
        var matchCriteria = Aggregation.match(Criteria.where("_id").is("67864e50ea02266d41daadad")); // ObectId which i get from database after saving the inital doc.
        var projection = Aggregation.project().andExpression("trunc('$test-key')").as("result");
        var aggregation = Aggregation.newAggregation(matchCriteria, projection);
        mongoTemplate.aggregate(aggregation, "test-collection", Document.class);
    }
}

Agg Produced By This is :

[{ "$match" : { "_id" : { "$oid" : "67864e50ea02266d41daadad"}}}, { "$project" : { "result" : { "$trunc" : "$test-key"}}}]

But Actual Query What I expected when i replace expression like this is "trunc('$test-key', 1)" is

[
  {
    $match: {
      _id: ObjectId("67864e50ea02266d41daadad")
    }
  },
  {
    $project: {
      result: { $trunc: ["$test-key", 1] }
    }
  }
]

But it still producing the previous agg!.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jan 14, 2025
@mp911de mp911de self-assigned this Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

3 participants