Skip to content

Commit

Permalink
Fix Query equality test considering Limit.
Browse files Browse the repository at this point in the history
Closes #4584
  • Loading branch information
mp911de committed Dec 8, 2023
1 parent a4fcbb1 commit e20d12f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ protected boolean querySettingsEquals(Query that) {
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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void testNorQuery() {
.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));
Expand All @@ -110,6 +110,9 @@ void testQueryWithLimit() {
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
Expand Down

0 comments on commit e20d12f

Please sign in to comment.