Skip to content

aggregate pipeline projected date field can not be recognized properly #6343

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

Open
victorx98 opened this issue Jan 15, 2020 · 1 comment
Open
Labels
type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@victorx98
Copy link

victorx98 commented Jan 15, 2020

Sourcefile: https://github.com/parse-community/parse-server/blob/master/src/Adapters/Storage/Mongo/MongoStorageAdapter.js

Function name: _parseAggregateArgs()

The purpose of the function is to

recursively traverse the pipeline and convert any Pointer or Date columns

But it can only recognize existing fields defined in the collection schema. If we create a new Data field in project stage, it can not recognize it and the query won't work.

Examples: any match on startTime will work, but not on endTime, which is generated in project stage.

var pipeline = [
    {match: {_p_user: "_User$"+userId},},
    {
      project: {
                _p_user: 1,
                startTime: 1,
                "endTime": {$add: ["$startTime", {$multiply: ["$duration",60000]}]}
                }
    },
// startTime can be recognized as Date() type, thus the query will work
    {match: {"startTime": {$gt: new Date()}}},
// endTime can not be recognized as Date type, any query on endTime will fail
    // {match: {"endTime": {$gt: new Date()}}},
    {limit: 10},
  ];

@davimacedo davimacedo added type:bug Impaired feature or lacking behavior that is likely assumed needs investigation labels Jan 16, 2020
@victorx98
Copy link
Author

I think issue #6333 is talking about the same problem. Maybe we can merge these two issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests

3 participants