Skip to content

Commit 4c611ac

Browse files
authored
refactor: change boolean config params to match Swift (#311)
1 parent 6a7f5c7 commit 4c611ac

File tree

93 files changed

+268
-266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+268
-266
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ __New features__
1515
- Adds isNull QueryConstraint along with the ability set/forceSet null using ParseOperation ([#308](https://github.com/parse-community/Parse-Swift/pull/308)), thanks to [Corey Baker](https://github.com/cbaker6).
1616

1717
__Improvements__
18+
- (Breaking Change) Change boolean configuration parameters to match Swift conventions. The compilor should help with name changes ([#311](https://github.com/parse-community/Parse-Swift/pull/311)), thanks to [Corey Baker](https://github.com/cbaker6).
1819
- Improve QueryWhere by making at a set of QueryConstraint's instead of any array. This dedupes the same constraint when encoding the query; improving the encoding speed when the same constraints are added ([#308](https://github.com/parse-community/Parse-Swift/pull/308)), thanks to [Corey Baker](https://github.com/cbaker6).
1920

2021
### 2.5.1
@@ -78,7 +79,7 @@ __Fixes__
7879
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/2.2.3...2.2.4)
7980

8081
__Fixes__
81-
- Delete all stored Parse data and cache when deleteKeychainIfNeeded is true ([#280](https://github.com/parse-community/Parse-Swift/pull/280)), thanks to [Corey Baker](https://github.com/cbaker6).
82+
- Delete all stored Parse data and cache when isDeletingKeychainIfNeeded is true ([#280](https://github.com/parse-community/Parse-Swift/pull/280)), thanks to [Corey Baker](https://github.com/cbaker6).
8283

8384
### 2.2.3
8485
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/2.2.2...2.2.3)
@@ -320,7 +321,7 @@ __Improvements__
320321
- Append instead of replace when using query select, exclude, include, and fields ([#155](https://github.com/parse-community/Parse-Swift/pull/155)), thanks to [Corey Baker](https://github.com/cbaker6).
321322

322323
__Fixes__
323-
- Transactions currently don't work when using MongoDB(postgres does work) on the parse-server. Internal use of transactions are disabled by default. If you want the Swift SDK to use transactions internally, you need to set useTransactionsInternally=true when configuring the client. It is recommended not to use transactions if you are using MongoDB until it's fixed on the server ([#158](https://github.com/parse-community/Parse-Swift/pull/158)), thanks to [Corey Baker](https://github.com/cbaker6).
324+
- Transactions currently don't work when using MongoDB(postgres does work) on the parse-server. Internal use of transactions are disabled by default. If you want the Swift SDK to use transactions internally, you need to set isUsingTransactionsInternally=true when configuring the client. It is recommended not to use transactions if you are using MongoDB until it's fixed on the server ([#158](https://github.com/parse-community/Parse-Swift/pull/158)), thanks to [Corey Baker](https://github.com/cbaker6).
324325

325326
### 1.8.0
326327
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.7.2...1.8.0)

ParseSwift.playground/Sources/Common.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ public func initializeParse() {
66
clientKey: "clientKey",
77
masterKey: "masterKey",
88
serverURL: URL(string: "http://localhost:1337/1")!,
9-
useTransactions: false)
9+
isUsingTransactions: false)
1010
}
1111

1212
public func initializeParseCustomObjectId() {
1313
ParseSwift.initialize(applicationId: "applicationId",
1414
clientKey: "clientKey",
1515
serverURL: URL(string: "http://localhost:1337/1")!,
16-
allowCustomObjectId: true)
16+
isAllowingCustomObjectIds: true)
1717
}

Sources/ParseSwift/API/API+Command.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,8 @@ internal extension API.Command {
386386
// MARK: Saving ParseObjects
387387
static func save<T>(_ object: T,
388388
isIgnoreCustomObjectIdConfig: Bool) throws -> API.Command<T, T> where T: ParseObject {
389-
if ParseSwift.configuration.allowCustomObjectId && object.objectId == nil && !isIgnoreCustomObjectIdConfig {
389+
if ParseSwift.configuration.isAllowingCustomObjectIds
390+
&& object.objectId == nil && !isIgnoreCustomObjectIdConfig {
390391
throw ParseError(code: .missingObjectId, message: "objectId must not be nil")
391392
}
392393
if object.isSaved {

Sources/ParseSwift/Coding/ParseEncoder.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public struct ParseEncoder {
126126
objectsSavedBeforeThisOne: [String: PointerType]?,
127127
filesSavedBeforeThisOne: [UUID: ParseFile]?) throws -> (encoded: Data, unique: PointerType?, unsavedChildren: [Encodable]) {
128128
let keysToSkip: Set<String>!
129-
if !ParseSwift.configuration.allowCustomObjectId {
129+
if !ParseSwift.configuration.isAllowingCustomObjectIds {
130130
keysToSkip = SkipKeys.object.keys()
131131
} else {
132132
keysToSkip = SkipKeys.customObjectId.keys()
@@ -148,7 +148,7 @@ public struct ParseEncoder {
148148
objectsSavedBeforeThisOne: [String: PointerType]?,
149149
filesSavedBeforeThisOne: [UUID: ParseFile]?) throws -> (encoded: Data, unique: PointerType?, unsavedChildren: [Encodable]) {
150150
let keysToSkip: Set<String>!
151-
if !ParseSwift.configuration.allowCustomObjectId {
151+
if !ParseSwift.configuration.isAllowingCustomObjectIds {
152152
keysToSkip = SkipKeys.object.keys()
153153
} else {
154154
keysToSkip = SkipKeys.customObjectId.keys()

Sources/ParseSwift/Objects/ParseInstallation+async.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ public extension ParseInstallation {
3737
/**
3838
Saves the `ParseInstallation` *asynchronously*.
3939
- parameter isIgnoreCustomObjectIdConfig: Ignore checking for `objectId`
40-
when `ParseConfiguration.allowCustomObjectId = true` to allow for mixed
40+
when `ParseConfiguration.isAllowingCustomObjectIds = true` to allow for mixed
4141
`objectId` environments. Defaults to false.
4242
- parameter options: A set of header options sent to the server. Defaults to an empty set.
4343
- returns: Returns saved `ParseInstallation`.
4444
- throws: An error of type `ParseError`.
4545
- important: If an object saved has the same objectId as current, it will automatically update the current.
46-
- warning: If you are using `ParseConfiguration.allowCustomObjectId = true`
46+
- warning: If you are using `ParseConfiguration.isAllowingCustomObjectIds = true`
4747
and plan to generate all of your `objectId`'s on the client-side then you should leave
4848
`isIgnoreCustomObjectIdConfig = false`. Setting
49-
`ParseConfiguration.allowCustomObjectId = true` and
49+
`ParseConfiguration.isAllowingCustomObjectIds = true` and
5050
`isIgnoreCustomObjectIdConfig = true` means the client will generate `objectId`'s
5151
and the server will generate an `objectId` only when the client does not provide one. This can
5252
increase the probability of colliiding `objectId`'s as the client and server `objectId`'s may be generated using
@@ -150,7 +150,7 @@ public extension Sequence where Element: ParseInstallation {
150150
- parameter transaction: Treat as an all-or-nothing operation. If some operation failure occurs that
151151
prevents the transaction from completing, then none of the objects are committed to the Parse Server database.
152152
- parameter isIgnoreCustomObjectIdConfig: Ignore checking for `objectId`
153-
when `ParseConfiguration.allowCustomObjectId = true` to allow for mixed
153+
when `ParseConfiguration.isAllowingCustomObjectIds = true` to allow for mixed
154154
`objectId` environments. Defaults to false.
155155
- parameter options: A set of header options sent to the server. Defaults to an empty set.
156156
- returns: Returns an array of Result enums with the object if a save was successful or a
@@ -160,10 +160,10 @@ public extension Sequence where Element: ParseInstallation {
160160
- warning: If `transaction = true`, then `batchLimit` will be automatically be set to the amount of the
161161
objects in the transaction. The developer should ensure their respective Parse Servers can handle the limit or else
162162
the transactions can fail.
163-
- warning: If you are using `ParseConfiguration.allowCustomObjectId = true`
163+
- warning: If you are using `ParseConfiguration.isAllowingCustomObjectIds = true`
164164
and plan to generate all of your `objectId`'s on the client-side then you should leave
165165
`isIgnoreCustomObjectIdConfig = false`. Setting
166-
`ParseConfiguration.allowCustomObjectId = true` and
166+
`ParseConfiguration.isAllowingCustomObjectIds = true` and
167167
`isIgnoreCustomObjectIdConfig = true` means the client will generate `objectId`'s
168168
and the server will generate an `objectId` only when the client does not provide one. This can
169169
increase the probability of colliiding `objectId`'s as the client and server `objectId`'s may be generated using
@@ -173,7 +173,7 @@ public extension Sequence where Element: ParseInstallation {
173173
desires a different policy, it should be inserted in `options`.
174174
*/
175175
func saveAll(batchLimit limit: Int? = nil,
176-
transaction: Bool = ParseSwift.configuration.useTransactions,
176+
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
177177
isIgnoreCustomObjectIdConfig: Bool = false,
178178
options: API.Options = []) async throws -> [(Result<Self.Element, ParseError>)] {
179179
try await withCheckedThrowingContinuation { continuation in
@@ -203,7 +203,7 @@ public extension Sequence where Element: ParseInstallation {
203203
desires a different policy, it should be inserted in `options`.
204204
*/
205205
func createAll(batchLimit limit: Int? = nil,
206-
transaction: Bool = ParseSwift.configuration.useTransactions,
206+
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
207207
options: API.Options = []) async throws -> [(Result<Self.Element, ParseError>)] {
208208
try await withCheckedThrowingContinuation { continuation in
209209
self.createAll(batchLimit: limit,
@@ -232,7 +232,7 @@ public extension Sequence where Element: ParseInstallation {
232232
desires a different policy, it should be inserted in `options`.
233233
*/
234234
func replaceAll(batchLimit limit: Int? = nil,
235-
transaction: Bool = ParseSwift.configuration.useTransactions,
235+
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
236236
options: API.Options = []) async throws -> [(Result<Self.Element, ParseError>)] {
237237
try await withCheckedThrowingContinuation { continuation in
238238
self.replaceAll(batchLimit: limit,
@@ -261,7 +261,7 @@ public extension Sequence where Element: ParseInstallation {
261261
desires a different policy, it should be inserted in `options`.
262262
*/
263263
internal func updateAll(batchLimit limit: Int? = nil,
264-
transaction: Bool = ParseSwift.configuration.useTransactions,
264+
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
265265
options: API.Options = []) async throws -> [(Result<Self.Element, ParseError>)] {
266266
try await withCheckedThrowingContinuation { continuation in
267267
self.updateAll(batchLimit: limit,
@@ -287,7 +287,7 @@ public extension Sequence where Element: ParseInstallation {
287287
the transactions can fail.
288288
*/
289289
func deleteAll(batchLimit limit: Int? = nil,
290-
transaction: Bool = ParseSwift.configuration.useTransactions,
290+
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
291291
options: API.Options = []) async throws -> [(Result<Void, ParseError>)] {
292292
try await withCheckedThrowingContinuation { continuation in
293293
self.deleteAll(batchLimit: limit,

Sources/ParseSwift/Objects/ParseInstallation+combine.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ public extension ParseInstallation {
3838
Saves the `ParseInstallation` *asynchronously* and publishes when complete.
3939

4040
- parameter isIgnoreCustomObjectIdConfig: Ignore checking for `objectId`
41-
when `ParseConfiguration.allowCustomObjectId = true` to allow for mixed
41+
when `ParseConfiguration.isAllowingCustomObjectIds = true` to allow for mixed
4242
`objectId` environments. Defaults to false.
4343
- parameter options: A set of header options sent to the server. Defaults to an empty set.
4444
- returns: A publisher that eventually produces a single value and then finishes or fails.
4545
- important: If an object saved has the same objectId as current, it will automatically update the current.
46-
- warning: If you are using `ParseConfiguration.allowCustomObjectId = true`
46+
- warning: If you are using `ParseConfiguration.isAllowingCustomObjectIds = true`
4747
and plan to generate all of your `objectId`'s on the client-side then you should leave
4848
`isIgnoreCustomObjectIdConfig = false`. Setting
49-
`ParseConfiguration.allowCustomObjectId = true` and
49+
`ParseConfiguration.isAllowingCustomObjectIds = true` and
5050
`isIgnoreCustomObjectIdConfig = true` means the client will generate `objectId`'s
5151
and the server will generate an `objectId` only when the client does not provide one. This can
5252
increase the probability of colliiding `objectId`'s as the client and server `objectId`'s may be generated using
@@ -148,7 +148,7 @@ public extension Sequence where Element: ParseInstallation {
148148
- parameter transaction: Treat as an all-or-nothing operation. If some operation failure occurs that
149149
prevents the transaction from completing, then none of the objects are committed to the Parse Server database.
150150
- parameter isIgnoreCustomObjectIdConfig: Ignore checking for `objectId`
151-
when `ParseConfiguration.allowCustomObjectId = true` to allow for mixed
151+
when `ParseConfiguration.isAllowingCustomObjectIds = true` to allow for mixed
152152
`objectId` environments. Defaults to false.
153153
- parameter options: A set of header options sent to the server. Defaults to an empty set.
154154
- returns: A publisher that eventually produces an an array of Result enums with the object if a save was
@@ -157,10 +157,10 @@ public extension Sequence where Element: ParseInstallation {
157157
- warning: If `transaction = true`, then `batchLimit` will be automatically be set to the amount of the
158158
objects in the transaction. The developer should ensure their respective Parse Servers can handle the limit or else
159159
the transactions can fail.
160-
- warning: If you are using `ParseConfiguration.allowCustomObjectId = true`
160+
- warning: If you are using `ParseConfiguration.isAllowingCustomObjectIds = true`
161161
and plan to generate all of your `objectId`'s on the client-side then you should leave
162162
`isIgnoreCustomObjectIdConfig = false`. Setting
163-
`ParseConfiguration.allowCustomObjectId = true` and
163+
`ParseConfiguration.isAllowingCustomObjectIds = true` and
164164
`isIgnoreCustomObjectIdConfig = true` means the client will generate `objectId`'s
165165
and the server will generate an `objectId` only when the client does not provide one. This can
166166
increase the probability of colliiding `objectId`'s as the client and server `objectId`'s may be generated using
@@ -170,7 +170,7 @@ public extension Sequence where Element: ParseInstallation {
170170
desires a different policy, it should be inserted in `options`.
171171
*/
172172
func saveAllPublisher(batchLimit limit: Int? = nil,
173-
transaction: Bool = ParseSwift.configuration.useTransactions,
173+
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
174174
isIgnoreCustomObjectIdConfig: Bool = false,
175175
options: API.Options = []) -> Future<[(Result<Self.Element, ParseError>)], ParseError> {
176176
Future { promise in
@@ -199,7 +199,7 @@ public extension Sequence where Element: ParseInstallation {
199199
desires a different policy, it should be inserted in `options`.
200200
*/
201201
func createAllPublisher(batchLimit limit: Int? = nil,
202-
transaction: Bool = ParseSwift.configuration.useTransactions,
202+
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
203203
options: API.Options = []) -> Future<[(Result<Self.Element, ParseError>)], ParseError> {
204204
Future { promise in
205205
self.createAll(batchLimit: limit,
@@ -227,7 +227,7 @@ public extension Sequence where Element: ParseInstallation {
227227
desires a different policy, it should be inserted in `options`.
228228
*/
229229
func replaceAllPublisher(batchLimit limit: Int? = nil,
230-
transaction: Bool = ParseSwift.configuration.useTransactions,
230+
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
231231
options: API.Options = []) -> Future<[(Result<Self.Element, ParseError>)], ParseError> {
232232
Future { promise in
233233
self.replaceAll(batchLimit: limit,
@@ -255,7 +255,7 @@ public extension Sequence where Element: ParseInstallation {
255255
desires a different policy, it should be inserted in `options`.
256256
*/
257257
internal func updateAllPublisher(batchLimit limit: Int? = nil,
258-
transaction: Bool = ParseSwift.configuration.useTransactions,
258+
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
259259
options: API.Options = []) -> Future<[(Result<Self.Element, ParseError>)],
260260
ParseError> {
261261
Future { promise in
@@ -282,7 +282,7 @@ public extension Sequence where Element: ParseInstallation {
282282
the transactions can fail.
283283
*/
284284
func deleteAllPublisher(batchLimit limit: Int? = nil,
285-
transaction: Bool = ParseSwift.configuration.useTransactions,
285+
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
286286
options: API.Options = []) -> Future<[(Result<Void, ParseError>)], ParseError> {
287287
Future { promise in
288288
self.deleteAll(batchLimit: limit,

0 commit comments

Comments
 (0)