[COMPASS-5742] Propagate aggregation/filter metadata to the transpiler's compile function Created: 15/Apr/22  Updated: 13/Dec/23

Status: Needs Triage
Project: Compass
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Minor - P4
Reporter: Preston Vasquez Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: COMPASS-7501

 Description   

Request

Propagate aggregation/filter information to the transpiler's compile function to be used by the underlying visitors to create branches of logic (e.g use bson.A for filter, mongo.Pipeline for aggregation).

Github conversation

Motivation

With the context of the go driver, it's more idiomatic to use mongo.Pipeline for aggregations rather than bson.A. That is, something like this:

[{
    $sort: {
        x: 1
    }
}]

Should output

mongo.Pipeline{
    bson.D{{"$sort", bson.D{{"x", 1}}}},
}

At the moment, the transpiler method used to make this export will use whatever is returned by ArrayTypeTemplate:

bson.A{
    bson.D{{"$sort", bson.D{{"x", 1}}}},
}

Both are valid code, the latter is just more correct and safer.

Proposal

Perhaps meta information about the export can be passed as an argument into compile. Right now compileWithDriver gets this information from the result, which seems reasonable.


Generated at Wed Feb 07 22:40:39 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.