From 702ca34b47a9512d39cc24d4b5b540391bcafea5 Mon Sep 17 00:00:00 2001 From: Corey Date: Mon, 11 Mar 2024 23:06:50 -0700 Subject: [PATCH] fix: Querying using findAll may return inacurrate results (#162) * fix: Querying using findAll may return inacurrate results * nit * try watchOS test * revert --- CHANGELOG.md | 8 +++++++- Sources/ParseSwift/ParseConstants.swift | 2 +- Sources/ParseSwift/Types/Query.swift | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4bbce182..b4fbf3faf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,16 @@ # Parse-Swift Changelog ### main -[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/5.9.1...main), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/main/documentation/parseswift) +[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/5.9.2...main), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/main/documentation/parseswift) * _Contributing to this repo? Add info about your change here to be included in the next release_ +### 5.9.2 +[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/5.9.1...5.9.2), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/5.9.2/documentation/parseswift) + +__Fixes__ +* Querying using findAll may be inacurrate when results are greater than the batch limit ([#161](https://github.com/netreconlab/Parse-Swift/pull/161)), thanks to [Corey Baker](https://github.com/cbaker6). + ### 5.9.1 [Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/5.9.0...5.9.1), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/5.9.1/documentation/parseswift) diff --git a/Sources/ParseSwift/ParseConstants.swift b/Sources/ParseSwift/ParseConstants.swift index 133c1cab3..608421dd7 100644 --- a/Sources/ParseSwift/ParseConstants.swift +++ b/Sources/ParseSwift/ParseConstants.swift @@ -10,7 +10,7 @@ import Foundation enum ParseConstants { static let sdk = "swift" - static let version = "5.9.1" + static let version = "5.9.2" static let fileManagementDirectory = "parse/" static let fileManagementPrivateDocumentsDirectory = "Private Documents/" static let fileManagementLibraryDirectory = "Library/" diff --git a/Sources/ParseSwift/Types/Query.swift b/Sources/ParseSwift/Types/Query.swift index eaba88c44..07cdac0f0 100644 --- a/Sources/ParseSwift/Types/Query.swift +++ b/Sources/ParseSwift/Types/Query.swift @@ -584,6 +584,7 @@ extension Query: Queryable { var query = self .order([.ascending("objectId")]) query.limit = limit ?? ParseConstants.batchLimit + let originalQueryWhere = query.where var results = [ResultType]() var finished = false while !finished { @@ -593,8 +594,9 @@ extension Query: Queryable { results.append(contentsOf: currentResults) if currentResults.count >= query.limit { guard let lastObjectId = results[results.count - 1].objectId else { - throw ParseError(code: .otherCause, message: "Last object should have an id.") + throw ParseError(code: .otherCause, message: "Last object should have an objectId.") } + query.where = originalQueryWhere query.where.add("objectId" > lastObjectId) } else { finished = true