Skip to content

Multiple group stage issue in aggregation pipeline #6068

Open
@ssafayet

Description

@ssafayet

Issue Description

Parse aggregation pipeline is throwing error on multiple group by. If the first group stage is based on a pointer field and second group stage is based on the number field then it is throwing error.

Steps to reproduce

var pipeline = [ { group: { objectId: '$user', totalScore: { $sum: '$score' } } }, { group: { objectId: '$totalScore', users: { $push: { userId: "$_id" } } } }, { sort: {objectId: -1}} ];

Expected Results

[ { "users": [ { "userId": "_User$odInwXlX1B" } ], "objectId": 50 }, { "users": [ { "userId": "_User$bnhHc22tfl" } ], "objectId": 10 } ]

Actual Outcome

Uncaught internal server error.result._id.split is not a function on line /node_modules/parse-server/lib/Adapters/Storage/Mongo/MongoStorageAdapter.js:596:15

Environment Setup

  • Server

    • parse-server version : 3.1.3
    • Operating System: Ubuntu 18.04
    • Hardware: Intel 4th Gen (2.2 Ghz) Dual Core, 16 GB Ram.
    • Localhost or remote server? : localhost
  • Database

    • MongoDB version: 3.6
    • Storage engine: WiredTiger
    • Hardware: Same as the previous
    • Localhost or remote server? : localhost

My Observation

On the second group stage, result._id is a number but storage adapter is trying to split it. And the reason it is trying to split it because isPointerField is being set as true due to the first group stage.

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