Skip to content

Commit 07d3636

Browse files
committed
[#258] Fix total_rows recount for case-insensitive queries
When Query.total_rows() is called on a GenQuery1 query with a non-zero offset, genquery.py issues a second query with offset=0 so iRODS can return the full row count. That recount query was being built via Query(...) without passing through the original case_sensitive setting. Because Query.__init__() defaults case_sensitive to True, the recount path cleared UPPER_CASE_WHERE and skipped uppercasing the condition string. This allowed a case-insensitive fetch query to be paired with a case-sensitive recount query, producing total_rows() values smaller than the number of rows actually returned. Use self.copy(offset=0, limit=0, ...) for the recount path so the original query attributes are preserved, including case sensitivity and the rest of the query configuration. This keeps the recount query aligned with the fetch query while still forcing RETURN_TOTAL_ROW_COUNT for the manual recount.
1 parent 7291262 commit 07d3636

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

genquery.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,11 @@ def total_rows(self):
267267
# So instead, we run the query twice manually. This should
268268
# perform only slightly worse.
269269
# [1]: https://github.com/irods/irods/blob/4.2.6/plugins/database/src/general_query.cpp#L2393
270-
self._total = Query(self.callback, self.columns, self.conditions, limit=0,
271-
options=self.options|Option.RETURN_TOTAL_ROW_COUNT).total_rows()
270+
# Preserve query attributes such as case_sensitive when
271+
# issuing the recount query.
272+
self._total = self.copy(offset=0,
273+
limit=0,
274+
options=self.options | Option.RETURN_TOTAL_ROW_COUNT).total_rows()
272275

273276
return self._total
274277

0 commit comments

Comments
 (0)