Skip to content

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

Open
@victorx98

Description

@victorx98

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},
  ];

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions