Skip to content

Commit 8978839

Browse files
committed
Fix, tests
1 parent 195e239 commit 8978839

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

driver-core/src/main/com/mongodb/client/model/expressions/MqlExpression.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ public <R extends Expression> ArrayExpression<R> isArrayOr(final ArrayExpression
504504
}
505505

506506
BooleanExpression isDocumentOrMap() {
507-
return new MqlExpression<>(ast("$type")).eq(of("object"));
507+
return new MqlExpression<>(astWrapped("$type")).eq(of("object"));
508508
}
509509

510510
@Override

driver-core/src/test/functional/com/mongodb/client/model/expressions/ControlExpressionsFunctionalTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public void switchTestInitial() {
205205
assertExpression("A",
206206
ofMap(Document.parse("{}")).switchOn(on -> on.isMap(v -> of("A"))),
207207
"{'$switch': {'branches': [{'case': {'$eq': [{'$type': "
208-
+ "{'$literal': {}}}, 'object']}, 'then': 'A'}]}}");
208+
+ "[{'$literal': {}}]}, 'object']}, 'then': 'A'}]}}");
209209
assertExpression("A",
210210
ofNull().switchOn(on -> on.isNull(v -> of("A"))),
211211
"{'$switch': {'branches': [{'case': {'$eq': [null, null]}, 'then': 'A'}]}}");
@@ -268,9 +268,8 @@ public void switchTestPartial() {
268268
+ "{'case': {'$eq': [{'$type': [{'$literal': {}}]}, 'object']}, 'then': 'A'}]}}");
269269
assertExpression("A",
270270
ofMap(Document.parse("{}")).switchOn(on -> on.isNull(v -> of("X")).isMap(v -> of("A"))),
271-
" {'$switch': {'branches': ["
272-
+ "{'case': {'$eq': [{'$literal': {}}, null]}, 'then': 'X'}, "
273-
+ "{'case': {'$eq': [{'$type': {'$literal': {}}}, 'object']}, 'then': 'A'}]}}");
271+
"{'$switch': {'branches': [{'case': {'$eq': [{'$literal': {}}, null]}, 'then': 'X'}, "
272+
+ "{'case': {'$eq': [{'$type': [{'$literal': {}}]}, 'object']}, 'then': 'A'}]}}");
274273
assertExpression("A",
275274
ofNull().switchOn(on -> on.isNumber(v -> of("X")).isNull(v -> of("A"))),
276275
"{'$switch': {'branches': [{'case': {'$isNumber': [null]}, 'then': 'X'}, "

driver-core/src/test/functional/com/mongodb/client/model/expressions/TypeExpressionsFunctionalTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public void isMapOrTest() {
152152
assertExpression(
153153
map,
154154
ofMap(map).isMapOr(ofMap(BsonDocument.parse("{b: 2}"))),
155-
"{'$cond': [{'$eq': [{'$type': {'$literal': {'a': 1}}}, 'object']}, "
155+
"{'$cond': [{'$eq': [{'$type': [{'$literal': {'a': 1}}]}, 'object']}, "
156156
+ "{'$literal': {'a': 1}}, {'$literal': {'b': 2}}]}");
157157
// non-map:
158158
assertExpression(map, ofIntegerArray(1).isMapOr(ofMap(map)));

0 commit comments

Comments
 (0)