Fix Query equality test considering Limit.

Closes #4584
This commit is contained in:
Mark Paluch
2023-12-08 14:24:53 +01:00
parent a4fcbb15bf
commit e20d12fe34
2 changed files with 5 additions and 2 deletions

View File

@@ -750,7 +750,7 @@ public class Query implements ReadConcernAware, ReadPreferenceAware {
boolean sortEqual = this.sort.equals(that.sort);
boolean hintEqual = nullSafeEquals(this.hint, that.hint);
boolean skipEqual = this.skip == that.skip;
boolean limitEqual = this.limit == that.limit;
boolean limitEqual = nullSafeEquals(this.limit, that.limit);
boolean metaEqual = nullSafeEquals(this.meta, that.meta);
boolean collationEqual = nullSafeEquals(this.collation.orElse(null), that.collation.orElse(null));

View File

@@ -89,7 +89,7 @@ class QueryTests {
.parse("{ \"$nor\" : [ { \"name\" : \"Sven\"} , { \"age\" : { \"$lt\" : 50}} , { \"name\" : \"Thomas\"}]}"));
}
@Test
@Test // GH-4584
void testQueryWithLimit() {
Query q = new Query(where("name").gte("M").lte("T").and("age").not().gt(22));
@@ -110,6 +110,9 @@ class QueryTests {
q.limit(Limit.of(-1));
assertThat(q.getLimit()).isZero();
assertThat(q.isLimited()).isFalse();
Query other = new Query(where("name").gte("M")).limit(Limit.of(10));
assertThat(new Query(where("name").gte("M")).limit(10)).isEqualTo(other).hasSameHashCodeAs(other);
}
@Test