File tree Expand file tree Collapse file tree 2 files changed +139
-0
lines changed
source/crud/tests/unified Expand file tree Collapse file tree 2 files changed +139
-0
lines changed Original file line number Diff line number Diff line change 44
44
"minServerVersion" : " 5.0"
45
45
}
46
46
],
47
+ "operations" : [
48
+ {
49
+ "name" : " aggregate" ,
50
+ "object" : " collection0" ,
51
+ "arguments" : {
52
+ "pipeline" : [
53
+ {
54
+ "$match" : {
55
+ "$expr" : {
56
+ "$eq" : [
57
+ " $_id" ,
58
+ " $$id"
59
+ ]
60
+ }
61
+ }
62
+ },
63
+ {
64
+ "$project" : {
65
+ "_id" : 0 ,
66
+ "x" : " $$x" ,
67
+ "y" : " $$y" ,
68
+ "rand" : " $$rand"
69
+ }
70
+ }
71
+ ],
72
+ "let" : {
73
+ "id" : 1 ,
74
+ "x" : " foo" ,
75
+ "y" : {
76
+ "$literal" : " bar"
77
+ },
78
+ "rand" : {
79
+ "$rand" : {}
80
+ }
81
+ }
82
+ },
83
+ "expectResult" : [
84
+ {
85
+ "x" : " foo" ,
86
+ "y" : " bar" ,
87
+ "rand" : {
88
+ "$$type" : " double"
89
+ }
90
+ }
91
+ ]
92
+ }
93
+ ],
94
+ "expectEvents" : [
95
+ {
96
+ "client" : " client0" ,
97
+ "events" : [
98
+ {
99
+ "commandStartedEvent" : {
100
+ "command" : {
101
+ "aggregate" : " coll0" ,
102
+ "pipeline" : [
103
+ {
104
+ "$match" : {
105
+ "$expr" : {
106
+ "$eq" : [
107
+ " $_id" ,
108
+ " $$id"
109
+ ]
110
+ }
111
+ }
112
+ },
113
+ {
114
+ "$project" : {
115
+ "_id" : 0 ,
116
+ "x" : " $$x" ,
117
+ "y" : " $$y" ,
118
+ "rand" : " $$rand"
119
+ }
120
+ }
121
+ ],
122
+ "let" : {
123
+ "id" : 1 ,
124
+ "x" : " foo" ,
125
+ "y" : {
126
+ "$literal" : " bar"
127
+ },
128
+ "rand" : {
129
+ "$rand" : {}
130
+ }
131
+ }
132
+ }
133
+ }
134
+ }
135
+ ]
136
+ }
137
+ ]
138
+ },
139
+ {
140
+ "description" : " Aggregate with let option and dollar-prefixed $literal value" ,
141
+ "runOnRequirements" : [
142
+ {
143
+ "minServerVersion" : " 5.0" ,
144
+ "topologies" : [
145
+ " single" ,
146
+ " replicaset"
147
+ ]
148
+ }
149
+ ],
47
150
"operations" : [
48
151
{
49
152
"name" : " aggregate" ,
Original file line number Diff line number Diff line change @@ -22,9 +22,45 @@ initialData: &initialData
22
22
- { _id: 1 }
23
23
24
24
tests :
25
+ # TODO: Once SERVER-57403 is resolved, this test can be removed in favor of
26
+ # the "dollar-prefixed $literal value" test below.
25
27
- description : " Aggregate with let option"
26
28
runOnRequirements :
27
29
- minServerVersion : " 5.0"
30
+ operations :
31
+ - name : aggregate
32
+ object : *collection0
33
+ arguments :
34
+ pipeline : &pipeline0
35
+ # $match takes a query expression, so $expr is necessary to utilize
36
+ # an aggregate expression context and access "let" variables.
37
+ - $match : { $expr: { $eq: ["$_id", "$$id"] } }
38
+ - $project : { _id: 0, x: "$$x", y: "$$y", rand: "$$rand" }
39
+ # Values in "let" must be constant or closed expressions that do not
40
+ # depend on document values. This test demonstrates a basic constant
41
+ # value, a value wrapped with $literal (to avoid expression parsing),
42
+ # and a closed expression (e.g. $rand).
43
+ let : &let0
44
+ id : 1
45
+ x : foo
46
+ y : { $literal: "bar" }
47
+ rand : { $rand: {} }
48
+ expectResult :
49
+ - { x: "foo", y: "bar", rand: { $$type: "double" } }
50
+ expectEvents :
51
+ - client : *client0
52
+ events :
53
+ - commandStartedEvent :
54
+ command :
55
+ aggregate : *collection0Name
56
+ pipeline : *pipeline0
57
+ let : *let0
58
+
59
+ - description : " Aggregate with let option and dollar-prefixed $literal value"
60
+ runOnRequirements :
61
+ - minServerVersion : " 5.0"
62
+ # TODO: Remove topology restrictions once SERVER-57403 is resolved
63
+ topologies : ["single", "replicaset"]
28
64
operations :
29
65
- name : aggregate
30
66
object : *collection0
You can’t perform that action at this time.
0 commit comments