Skip to content

Commit 81e3abb

Browse files
ternary nullness logic implementation
1 parent 5a58a8c commit 81e3abb

File tree

8 files changed

+1042
-416
lines changed

8 files changed

+1042
-416
lines changed

src/integrationTest/java/com/mongodb/hibernate/query/select/Book.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@ class Book {
4343
this.outOfStock = outOfStock;
4444
}
4545

46+
public Book(
47+
int id,
48+
String title,
49+
Integer publishYear,
50+
Boolean outOfStock,
51+
Long isbn13,
52+
Double discount,
53+
BigDecimal price) {
54+
this(id, title, publishYear, outOfStock);
55+
this.isbn13 = isbn13;
56+
this.discount = discount;
57+
this.price = price;
58+
}
59+
4660
@Override
4761
public String toString() {
4862
return "Book{" + "id=" + id + '}';

src/integrationTest/java/com/mongodb/hibernate/query/select/BooleanExpressionWhereClauseIntegrationTests.java

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,41 @@ void testBooleanFieldPathExpression(boolean negated) {
5454
assertSelectionQuery(
5555
"from Book where" + (negated ? " not " : " ") + "outOfStock",
5656
Book.class,
57-
"{'aggregate': 'books', 'pipeline': [{'$match': {'outOfStock': {'$eq': "
58-
+ (negated ? "false" : "true")
59-
+ "}}}, {'$project': {'_id': true, 'discount': true, 'isbn13': true, 'outOfStock': true, 'price': true, 'publishYear': true, 'title': true}}]}",
57+
"""
58+
{
59+
"aggregate": "books",
60+
"pipeline": [
61+
{
62+
"$match": {
63+
"$and": [
64+
{
65+
"outOfStock": {
66+
"$eq": %s
67+
}
68+
},
69+
{
70+
"outOfStock": {
71+
"$ne": null
72+
}
73+
}
74+
]
75+
}
76+
},
77+
{
78+
"$project": {
79+
"_id": true,
80+
"discount": true,
81+
"isbn13": true,
82+
"outOfStock": true,
83+
"price": true,
84+
"publishYear": true,
85+
"title": true
86+
}
87+
}
88+
]
89+
}
90+
"""
91+
.formatted(negated ? "false" : "true"),
6092
negated ? singletonList(bookInStock) : singletonList(bookOutOfStock));
6193
}
6294

0 commit comments

Comments
 (0)