parse-community / Parse-SDK-JS

The JavaScript SDK for Parse Platform
https://parseplatform.org
Apache License 2.0
1.33k stars 597 forks source link

Parse.Query.toJSON() not working for aggregate query #918

Open mtrezza opened 5 years ago

mtrezza commented 5 years ago

Issue Description

Parse.Query.toJSON() returns an empty query when the query is an aggregate query.

Steps to reproduce

const query = new Parse.Query("MyCollection");
const pipeline = {
    "match":{"language":{"$in":[null,"en"]}},
};
const results = await query.aggregate(pipeline);
const queryJson = query.toJSON(); // returns `{where: {}}`

Expected Results

query.toJSON() should return the aggregate query.

Actual Outcome

query.toJSON() returns {where: {}}.

Environment Setup

Logs/Trace

-

dplewis commented 5 years ago

You want to implement query.setPipeline()?

mtrezza commented 5 years ago

Actually I will close this for now if that's OK, there may be more important issues/feature requests coming up. At least we have it documented here.

RaschidJFR commented 4 years ago

@mtrezza what's your use case for this feature?

mtrezza commented 4 years ago

@RaschidJFR why are you asking?

Sent with GitHawk

dplewis commented 4 years ago

I forgot about this feature, I can do a PR if you want

mtrezza commented 4 years ago

No-one has voiced any need for it to my knowledge, and I personally don’t need it anymore, but it would certainly be a nice-to-have feature.

Sent with GitHawk

RaschidJFR commented 4 years ago

@RaschidJFR why are you asking?

Sent with GitHawk

Because I've just started working on #1170 and I thought it might be related.

mtrezza commented 4 years ago

@RaschidJFR Related in what sense?

This issue is about the pipeline not being serialized with toJSON(). Your PR seems to be about mixing the equalTo condition into the pipeline.

Can you please open an issue for your PR where you describe your intention, so the community can debate it if necessary? I already see some potential issues with that PR.

RaschidJFR commented 4 years ago

Related in what sense?

@mtrezza I was just gathering information about similar problems to mine to try to solve them at once. Your issue is caused because aggregate() is executes the query but does not modify it, same as find() (they are sibling functions). So if you don't have a use for it anymore I'll just ignore it in my proposal.

I've created #1171 so let's move the conversation there. Please list the potential issues you've found.

RaschidJFR commented 4 years ago

I forgot about this feature, I can do a PR if you want @dplewis Please have a look at my PR #1170 and let me know if you need me to include anything else in case it goes ahead.

zanderisrael commented 2 years ago

I'd love to have this feature. I there something I can do to help this move along?

mtrezza commented 2 years ago

Thanks for asking @zanderisrael, you could open a PR. To my knowledge no-one has worked on it so far. It seems fairly straight forward, because a lot of the logic to produce the JSON output for non-aggregate queries already exists.

zanderisrael commented 2 years ago

Ok then, i'll have a look.

zanderisrael commented 2 years ago

Looks like I don't need this in the end. Someone else can pick this up...