Skip to content

Commit e23eaa5

Browse files
committed
feat: allow includeAll with additional includes
1 parent 550939f commit e23eaa5

File tree

6 files changed

+14
-4
lines changed

6 files changed

+14
-4
lines changed

Sources/ParseSwift/API/API+Command.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ internal extension API.Command {
474474

475475
var params: [String: String]?
476476
if let includeParams = include {
477-
params = ["include": "\(includeParams)"]
477+
params = ["include": "\(Set(includeParams))"]
478478
}
479479

480480
return API.Command<T, T>(

Sources/ParseSwift/Objects/ParseInstallation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ extension ParseInstallation {
508508

509509
var params: [String: String]?
510510
if let includeParams = include {
511-
params = ["include": "\(includeParams)"]
511+
params = ["include": "\(Set(includeParams))"]
512512
}
513513

514514
return API.Command(method: .GET,

Sources/ParseSwift/Objects/ParseUser.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ extension ParseUser {
916916

917917
var params: [String: String]?
918918
if let includeParams = include {
919-
params = ["include": "\(includeParams)"]
919+
params = ["include": "\(Set(includeParams))"]
920920
}
921921

922922
return API.Command(method: .GET,

Sources/ParseSwift/ParseConstants.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ enum ParseConstants {
1717
static let fileDownloadsDirectory = "Downloads"
1818
static let bundlePrefix = "com.parse.ParseSwift"
1919
static let batchLimit = 50
20+
static let includeAllKey = "*"
2021
#if os(iOS)
2122
static let deviceType = "ios"
2223
#elseif os(macOS)

Sources/ParseSwift/Types/Query.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,11 @@ public struct Query<T>: Encodable, Equatable where T: ParseObject {
259259
*/
260260
public func includeAll() -> Query<T> {
261261
var mutableQuery = self
262-
mutableQuery.include = ["*"]
262+
if mutableQuery.include != nil {
263+
mutableQuery.include?.insert(ParseConstants.includeAllKey)
264+
} else {
265+
mutableQuery.include = [ParseConstants.includeAllKey]
266+
}
263267
return mutableQuery
264268
}
265269

Tests/ParseSwiftTests/ParseQueryTests.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ class ParseQueryTests: XCTestCase { // swiftlint:disable:this type_body_length
205205
let query2 = GameScore.query.includeAll()
206206
XCTAssertEqual(query2.include?.count, 1)
207207
XCTAssertEqual(query2.include, ["*"])
208+
let query3 = GameScore.query
209+
.include("hello")
210+
.includeAll()
211+
XCTAssertEqual(query3.include?.count, 2)
212+
XCTAssertEqual(query3.include, Set(["hello", "*"]))
208213
}
209214

210215
func testExcludeKeys() throws {

0 commit comments

Comments
 (0)