Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions mql/agg/accumulator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func TestAvgAccumulator_UseInGroupStage(t *testing.T) {

func TestBottomAccumulator_FindBottomScore(t *testing.T) {
got := agg.Pipeline{
agg.MatchStage(query.Field("gameId", "G1")),
agg.MatchStage(query.Field("gameId", query.Eq("G1"))),
agg.GroupStage(
"$gameId",
agg.Accumulate("playerId", agg.BottomAccumulator(
Expand All @@ -193,7 +193,7 @@ func TestBottomAccumulator_FindBottomScore(t *testing.T) {
),
}
want := bson.A{
bson.D{{Key: "$match", Value: bson.D{{Key: "gameId", Value: "G1"}}}},
bson.D{{Key: "$match", Value: bson.D{{Key: "gameId", Value: bson.D{{Key: "$eq", Value: "G1"}}}}}},
bson.D{{Key: "$group", Value: bson.D{
{Key: "_id", Value: "$gameId"},
{Key: "playerId", Value: bson.D{{Key: "$bottom", Value: bson.D{
Expand Down Expand Up @@ -231,7 +231,7 @@ func TestBottomAccumulator_FindBottomScoreAcrossMultipleGames(t *testing.T) {

func TestBottomNAccumulator_FindThreeLowestScores(t *testing.T) {
got := agg.Pipeline{
agg.MatchStage(query.Field("gameId", "G1")),
agg.MatchStage(query.Field("gameId", query.Eq("G1"))),
agg.GroupStage(
"$gameId",
agg.Accumulate("playerId", agg.BottomNAccumulator(
Expand All @@ -242,7 +242,7 @@ func TestBottomNAccumulator_FindThreeLowestScores(t *testing.T) {
),
}
want := bson.A{
bson.D{{Key: "$match", Value: bson.D{{Key: "gameId", Value: "G1"}}}},
bson.D{{Key: "$match", Value: bson.D{{Key: "gameId", Value: bson.D{{Key: "$eq", Value: "G1"}}}}}},
bson.D{{Key: "$group", Value: bson.D{
{Key: "_id", Value: "$gameId"},
{Key: "playerId", Value: bson.D{{Key: "$bottomN", Value: bson.D{
Expand Down Expand Up @@ -383,7 +383,7 @@ func TestFirstAccumulator_UseInGroupStage(t *testing.T) {

func TestFirstNAccumulator_FindFirstThreePlayerScoresForSingleGame(t *testing.T) {
got := agg.Pipeline{
agg.MatchStage(query.Field("gameId", "G1")),
agg.MatchStage(query.Field("gameId", query.Eq("G1"))),
agg.GroupStage(
"$gameId",
agg.Accumulate("firstThreeScores", agg.FirstNAccumulator(
Expand All @@ -393,7 +393,7 @@ func TestFirstNAccumulator_FindFirstThreePlayerScoresForSingleGame(t *testing.T)
),
}
want := bson.A{
bson.D{{Key: "$match", Value: bson.D{{Key: "gameId", Value: "G1"}}}},
bson.D{{Key: "$match", Value: bson.D{{Key: "gameId", Value: bson.D{{Key: "$eq", Value: "G1"}}}}}},
bson.D{{Key: "$group", Value: bson.D{
{Key: "_id", Value: "$gameId"},
{Key: "firstThreeScores", Value: bson.D{{Key: "$firstN", Value: bson.D{
Expand Down Expand Up @@ -492,7 +492,7 @@ func TestLastAccumulator_UseInGroupStage(t *testing.T) {

func TestLastNAccumulator_FindLastThreePlayerScoresForSingleGame(t *testing.T) {
got := agg.Pipeline{
agg.MatchStage(query.Field("gameId", "G1")),
agg.MatchStage(query.Field("gameId", query.Eq("G1"))),
agg.GroupStage(
"$gameId",
agg.Accumulate("lastThreeScores", agg.LastNAccumulator(
Expand All @@ -502,7 +502,7 @@ func TestLastNAccumulator_FindLastThreePlayerScoresForSingleGame(t *testing.T) {
),
}
want := bson.A{
bson.D{{Key: "$match", Value: bson.D{{Key: "gameId", Value: "G1"}}}},
bson.D{{Key: "$match", Value: bson.D{{Key: "gameId", Value: bson.D{{Key: "$eq", Value: "G1"}}}}}},
bson.D{{Key: "$group", Value: bson.D{
{Key: "_id", Value: "$gameId"},
{Key: "lastThreeScores", Value: bson.D{{Key: "$lastN", Value: bson.D{
Expand Down Expand Up @@ -600,7 +600,7 @@ func TestMaxAccumulator_UseInGroupStage(t *testing.T) {

func TestMaxNAccumulator_FindMaxThreeScoresForSingleGame(t *testing.T) {
got := agg.Pipeline{
agg.MatchStage(query.Field("gameId", "G1")),
agg.MatchStage(query.Field("gameId", query.Eq("G1"))),
agg.GroupStage(
"$gameId",
agg.Accumulate("maxThreeScores", agg.MaxNAccumulator(
Expand All @@ -610,7 +610,7 @@ func TestMaxNAccumulator_FindMaxThreeScoresForSingleGame(t *testing.T) {
),
}
want := bson.A{
bson.D{{Key: "$match", Value: bson.D{{Key: "gameId", Value: "G1"}}}},
bson.D{{Key: "$match", Value: bson.D{{Key: "gameId", Value: bson.D{{Key: "$eq", Value: "G1"}}}}}},
bson.D{{Key: "$group", Value: bson.D{
{Key: "_id", Value: "$gameId"},
{Key: "maxThreeScores", Value: bson.D{{Key: "$maxN", Value: bson.D{
Expand Down Expand Up @@ -723,7 +723,7 @@ func TestMinAccumulator_UseInGroupStage(t *testing.T) {

func TestMinNAccumulator_FindMinThreeScoresForSingleGame(t *testing.T) {
got := agg.Pipeline{
agg.MatchStage(query.Field("gameId", "G1")),
agg.MatchStage(query.Field("gameId", query.Eq("G1"))),
agg.GroupStage(
"$gameId",
agg.Accumulate("minScores", agg.MinNAccumulator(
Expand All @@ -733,7 +733,7 @@ func TestMinNAccumulator_FindMinThreeScoresForSingleGame(t *testing.T) {
),
}
want := bson.A{
bson.D{{Key: "$match", Value: bson.D{{Key: "gameId", Value: "G1"}}}},
bson.D{{Key: "$match", Value: bson.D{{Key: "gameId", Value: bson.D{{Key: "$eq", Value: "G1"}}}}}},
bson.D{{Key: "$group", Value: bson.D{
{Key: "_id", Value: "$gameId"},
{Key: "minScores", Value: bson.D{{Key: "$minN", Value: bson.D{
Expand Down Expand Up @@ -999,7 +999,7 @@ func TestSumAccumulator_UseInGroupStage(t *testing.T) {

func TestTopAccumulator_FindTopScore(t *testing.T) {
got := agg.Pipeline{
agg.MatchStage(query.Field("gameId", "G1")),
agg.MatchStage(query.Field("gameId", query.Eq("G1"))),
agg.GroupStage(
"$gameId",
agg.Accumulate("playerId", agg.TopAccumulator(
Expand All @@ -1009,7 +1009,7 @@ func TestTopAccumulator_FindTopScore(t *testing.T) {
),
}
want := bson.A{
bson.D{{Key: "$match", Value: bson.D{{Key: "gameId", Value: "G1"}}}},
bson.D{{Key: "$match", Value: bson.D{{Key: "gameId", Value: bson.D{{Key: "$eq", Value: "G1"}}}}}},
bson.D{{Key: "$group", Value: bson.D{
{Key: "_id", Value: "$gameId"},
{Key: "playerId", Value: bson.D{{Key: "$top", Value: bson.D{
Expand Down Expand Up @@ -1047,7 +1047,7 @@ func TestTopAccumulator_FindTopScoreAcrossMultipleGames(t *testing.T) {

func TestTopNAccumulator_FindThreeHighestScores(t *testing.T) {
got := agg.Pipeline{
agg.MatchStage(query.Field("gameId", "G1")),
agg.MatchStage(query.Field("gameId", query.Eq("G1"))),
agg.GroupStage(
"$gameId",
agg.Accumulate("playerId", agg.TopNAccumulator(
Expand All @@ -1058,7 +1058,7 @@ func TestTopNAccumulator_FindThreeHighestScores(t *testing.T) {
),
}
want := bson.A{
bson.D{{Key: "$match", Value: bson.D{{Key: "gameId", Value: "G1"}}}},
bson.D{{Key: "$match", Value: bson.D{{Key: "gameId", Value: bson.D{{Key: "$eq", Value: "G1"}}}}}},
bson.D{{Key: "$group", Value: bson.D{
{Key: "_id", Value: "$gameId"},
{Key: "playerId", Value: bson.D{{Key: "$topN", Value: bson.D{
Expand Down
2 changes: 1 addition & 1 deletion mql/agg/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type StringResolver interface {
}

type BoolResolver interface {
AnyExpr | BoolExpr | bool
AnyExpr | BoolExpr | bool | string
}

type ObjectResolver interface {
Expand Down
Loading
Loading