This is an automated email from the ASF dual-hosted git repository.
jdaugherty pushed a commit to branch 8.0.x-hibernate7
in repository https://gitbox.apache.org/repos/asf/grails-core.git
The following commit(s) were added to refs/heads/8.0.x-hibernate7 by this push:
new 8c2ad15b1a Handle null values for MongoQuery
8c2ad15b1a is described below
commit 8c2ad15b1a27a61360572436c89cb122de2d1e50
Author: James Daugherty <[email protected]>
AuthorDate: Mon Mar 23 11:24:13 2026 -0400
Handle null values for MongoQuery
---
.../org/grails/datastore/mapping/mongo/query/MongoQuery.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git
a/grails-data-mongodb/core/src/main/groovy/org/grails/datastore/mapping/mongo/query/MongoQuery.java
b/grails-data-mongodb/core/src/main/groovy/org/grails/datastore/mapping/mongo/query/MongoQuery.java
index 586b78763a..a7f0ec6c4d 100644
---
a/grails-data-mongodb/core/src/main/groovy/org/grails/datastore/mapping/mongo/query/MongoQuery.java
+++
b/grails-data-mongodb/core/src/main/groovy/org/grails/datastore/mapping/mongo/query/MongoQuery.java
@@ -574,10 +574,10 @@ public class MongoQuery extends BsonQuery implements
QueryArgumentsAware {
}
final FindIterable<Document> iterable = collection.find(query);
- if (offset > 0) {
+ if (offset != null && offset > 0) {
iterable.skip(offset);
}
- if (max > -1) {
+ if (max != null && max > -1) {
iterable.limit(max);
}
if (uniqueResult) {
@@ -1473,11 +1473,11 @@ public class MongoQuery extends BsonQuery implements
QueryArgumentsAware {
aggregationPipeline.add(sort);
}
- int max = mongoQuery.max;
+ int max = mongoQuery.max != null ? mongoQuery.max : -1;
if (max > 0) {
aggregationPipeline.add(new Document("$limit", max));
}
- int offset = mongoQuery.offset;
+ int offset = mongoQuery.offset != null ? mongoQuery.offset : 0;
if (offset > 0) {
aggregationPipeline.add(new Document("$skip", offset));
}