Skip to content

Commit

Permalink
refactor: change boolean config params to match Swift
Browse files Browse the repository at this point in the history
  • Loading branch information
cbaker6 committed Jan 3, 2022
1 parent 6a7f5c7 commit 2ee5ab8
Show file tree
Hide file tree
Showing 93 changed files with 268 additions and 266 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ __New features__
- 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).

__Improvements__
- (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).
- 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).

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

__Fixes__
- 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).
- 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).

### 2.2.3
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/2.2.2...2.2.3)
Expand Down Expand Up @@ -320,7 +321,7 @@ __Improvements__
- 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).

__Fixes__
- 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).
- 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).

### 1.8.0
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.7.2...1.8.0)
Expand Down
4 changes: 2 additions & 2 deletions ParseSwift.playground/Sources/Common.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ public func initializeParse() {
clientKey: "clientKey",
masterKey: "masterKey",
serverURL: URL(string: "http://localhost:1337/1")!,
useTransactions: false)
isUsingTransactions: false)
}

public func initializeParseCustomObjectId() {
ParseSwift.initialize(applicationId: "applicationId",
clientKey: "clientKey",
serverURL: URL(string: "http://localhost:1337/1")!,
allowCustomObjectId: true)
isAllowingCustomObjectIds: true)
}
3 changes: 2 additions & 1 deletion Sources/ParseSwift/API/API+Command.swift
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,8 @@ internal extension API.Command {
// MARK: Saving ParseObjects
static func save<T>(_ object: T,
isIgnoreCustomObjectIdConfig: Bool) throws -> API.Command<T, T> where T: ParseObject {
if ParseSwift.configuration.allowCustomObjectId && object.objectId == nil && !isIgnoreCustomObjectIdConfig {
if ParseSwift.configuration.isAllowingCustomObjectIds
&& object.objectId == nil && !isIgnoreCustomObjectIdConfig {
throw ParseError(code: .missingObjectId, message: "objectId must not be nil")
}
if object.isSaved {
Expand Down
4 changes: 2 additions & 2 deletions Sources/ParseSwift/Coding/ParseEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public struct ParseEncoder {
objectsSavedBeforeThisOne: [String: PointerType]?,
filesSavedBeforeThisOne: [UUID: ParseFile]?) throws -> (encoded: Data, unique: PointerType?, unsavedChildren: [Encodable]) {
let keysToSkip: Set<String>!
if !ParseSwift.configuration.allowCustomObjectId {
if !ParseSwift.configuration.isAllowingCustomObjectIds {
keysToSkip = SkipKeys.object.keys()
} else {
keysToSkip = SkipKeys.customObjectId.keys()
Expand All @@ -148,7 +148,7 @@ public struct ParseEncoder {
objectsSavedBeforeThisOne: [String: PointerType]?,
filesSavedBeforeThisOne: [UUID: ParseFile]?) throws -> (encoded: Data, unique: PointerType?, unsavedChildren: [Encodable]) {
let keysToSkip: Set<String>!
if !ParseSwift.configuration.allowCustomObjectId {
if !ParseSwift.configuration.isAllowingCustomObjectIds {
keysToSkip = SkipKeys.object.keys()
} else {
keysToSkip = SkipKeys.customObjectId.keys()
Expand Down
22 changes: 11 additions & 11 deletions Sources/ParseSwift/Objects/ParseInstallation+async.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ public extension ParseInstallation {
/**
Saves the `ParseInstallation` *asynchronously*.
- parameter isIgnoreCustomObjectIdConfig: Ignore checking for `objectId`
when `ParseConfiguration.allowCustomObjectId = true` to allow for mixed
when `ParseConfiguration.isAllowingCustomObjectIds = true` to allow for mixed
`objectId` environments. Defaults to false.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: Returns saved `ParseInstallation`.
- throws: An error of type `ParseError`.
- important: If an object saved has the same objectId as current, it will automatically update the current.
- warning: If you are using `ParseConfiguration.allowCustomObjectId = true`
- warning: If you are using `ParseConfiguration.isAllowingCustomObjectIds = true`
and plan to generate all of your `objectId`'s on the client-side then you should leave
`isIgnoreCustomObjectIdConfig = false`. Setting
`ParseConfiguration.allowCustomObjectId = true` and
`ParseConfiguration.isAllowingCustomObjectIds = true` and
`isIgnoreCustomObjectIdConfig = true` means the client will generate `objectId`'s
and the server will generate an `objectId` only when the client does not provide one. This can
increase the probability of colliiding `objectId`'s as the client and server `objectId`'s may be generated using
Expand Down Expand Up @@ -150,7 +150,7 @@ public extension Sequence where Element: ParseInstallation {
- parameter transaction: Treat as an all-or-nothing operation. If some operation failure occurs that
prevents the transaction from completing, then none of the objects are committed to the Parse Server database.
- parameter isIgnoreCustomObjectIdConfig: Ignore checking for `objectId`
when `ParseConfiguration.allowCustomObjectId = true` to allow for mixed
when `ParseConfiguration.isAllowingCustomObjectIds = true` to allow for mixed
`objectId` environments. Defaults to false.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: Returns an array of Result enums with the object if a save was successful or a
Expand All @@ -160,10 +160,10 @@ public extension Sequence where Element: ParseInstallation {
- warning: If `transaction = true`, then `batchLimit` will be automatically be set to the amount of the
objects in the transaction. The developer should ensure their respective Parse Servers can handle the limit or else
the transactions can fail.
- warning: If you are using `ParseConfiguration.allowCustomObjectId = true`
- warning: If you are using `ParseConfiguration.isAllowingCustomObjectIds = true`
and plan to generate all of your `objectId`'s on the client-side then you should leave
`isIgnoreCustomObjectIdConfig = false`. Setting
`ParseConfiguration.allowCustomObjectId = true` and
`ParseConfiguration.isAllowingCustomObjectIds = true` and
`isIgnoreCustomObjectIdConfig = true` means the client will generate `objectId`'s
and the server will generate an `objectId` only when the client does not provide one. This can
increase the probability of colliiding `objectId`'s as the client and server `objectId`'s may be generated using
Expand All @@ -173,7 +173,7 @@ public extension Sequence where Element: ParseInstallation {
desires a different policy, it should be inserted in `options`.
*/
func saveAll(batchLimit limit: Int? = nil,
transaction: Bool = ParseSwift.configuration.useTransactions,
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
isIgnoreCustomObjectIdConfig: Bool = false,
options: API.Options = []) async throws -> [(Result<Self.Element, ParseError>)] {
try await withCheckedThrowingContinuation { continuation in
Expand Down Expand Up @@ -203,7 +203,7 @@ public extension Sequence where Element: ParseInstallation {
desires a different policy, it should be inserted in `options`.
*/
func createAll(batchLimit limit: Int? = nil,
transaction: Bool = ParseSwift.configuration.useTransactions,
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
options: API.Options = []) async throws -> [(Result<Self.Element, ParseError>)] {
try await withCheckedThrowingContinuation { continuation in
self.createAll(batchLimit: limit,
Expand Down Expand Up @@ -232,7 +232,7 @@ public extension Sequence where Element: ParseInstallation {
desires a different policy, it should be inserted in `options`.
*/
func replaceAll(batchLimit limit: Int? = nil,
transaction: Bool = ParseSwift.configuration.useTransactions,
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
options: API.Options = []) async throws -> [(Result<Self.Element, ParseError>)] {
try await withCheckedThrowingContinuation { continuation in
self.replaceAll(batchLimit: limit,
Expand Down Expand Up @@ -261,7 +261,7 @@ public extension Sequence where Element: ParseInstallation {
desires a different policy, it should be inserted in `options`.
*/
internal func updateAll(batchLimit limit: Int? = nil,
transaction: Bool = ParseSwift.configuration.useTransactions,
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
options: API.Options = []) async throws -> [(Result<Self.Element, ParseError>)] {
try await withCheckedThrowingContinuation { continuation in
self.updateAll(batchLimit: limit,
Expand All @@ -287,7 +287,7 @@ public extension Sequence where Element: ParseInstallation {
the transactions can fail.
*/
func deleteAll(batchLimit limit: Int? = nil,
transaction: Bool = ParseSwift.configuration.useTransactions,
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
options: API.Options = []) async throws -> [(Result<Void, ParseError>)] {
try await withCheckedThrowingContinuation { continuation in
self.deleteAll(batchLimit: limit,
Expand Down
22 changes: 11 additions & 11 deletions Sources/ParseSwift/Objects/ParseInstallation+combine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ public extension ParseInstallation {
Saves the `ParseInstallation` *asynchronously* and publishes when complete.

- parameter isIgnoreCustomObjectIdConfig: Ignore checking for `objectId`
when `ParseConfiguration.allowCustomObjectId = true` to allow for mixed
when `ParseConfiguration.isAllowingCustomObjectIds = true` to allow for mixed
`objectId` environments. Defaults to false.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: A publisher that eventually produces a single value and then finishes or fails.
- important: If an object saved has the same objectId as current, it will automatically update the current.
- warning: If you are using `ParseConfiguration.allowCustomObjectId = true`
- warning: If you are using `ParseConfiguration.isAllowingCustomObjectIds = true`
and plan to generate all of your `objectId`'s on the client-side then you should leave
`isIgnoreCustomObjectIdConfig = false`. Setting
`ParseConfiguration.allowCustomObjectId = true` and
`ParseConfiguration.isAllowingCustomObjectIds = true` and
`isIgnoreCustomObjectIdConfig = true` means the client will generate `objectId`'s
and the server will generate an `objectId` only when the client does not provide one. This can
increase the probability of colliiding `objectId`'s as the client and server `objectId`'s may be generated using
Expand Down Expand Up @@ -148,7 +148,7 @@ public extension Sequence where Element: ParseInstallation {
- parameter transaction: Treat as an all-or-nothing operation. If some operation failure occurs that
prevents the transaction from completing, then none of the objects are committed to the Parse Server database.
- parameter isIgnoreCustomObjectIdConfig: Ignore checking for `objectId`
when `ParseConfiguration.allowCustomObjectId = true` to allow for mixed
when `ParseConfiguration.isAllowingCustomObjectIds = true` to allow for mixed
`objectId` environments. Defaults to false.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: A publisher that eventually produces an an array of Result enums with the object if a save was
Expand All @@ -157,10 +157,10 @@ public extension Sequence where Element: ParseInstallation {
- warning: If `transaction = true`, then `batchLimit` will be automatically be set to the amount of the
objects in the transaction. The developer should ensure their respective Parse Servers can handle the limit or else
the transactions can fail.
- warning: If you are using `ParseConfiguration.allowCustomObjectId = true`
- warning: If you are using `ParseConfiguration.isAllowingCustomObjectIds = true`
and plan to generate all of your `objectId`'s on the client-side then you should leave
`isIgnoreCustomObjectIdConfig = false`. Setting
`ParseConfiguration.allowCustomObjectId = true` and
`ParseConfiguration.isAllowingCustomObjectIds = true` and
`isIgnoreCustomObjectIdConfig = true` means the client will generate `objectId`'s
and the server will generate an `objectId` only when the client does not provide one. This can
increase the probability of colliiding `objectId`'s as the client and server `objectId`'s may be generated using
Expand All @@ -170,7 +170,7 @@ public extension Sequence where Element: ParseInstallation {
desires a different policy, it should be inserted in `options`.
*/
func saveAllPublisher(batchLimit limit: Int? = nil,
transaction: Bool = ParseSwift.configuration.useTransactions,
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
isIgnoreCustomObjectIdConfig: Bool = false,
options: API.Options = []) -> Future<[(Result<Self.Element, ParseError>)], ParseError> {
Future { promise in
Expand Down Expand Up @@ -199,7 +199,7 @@ public extension Sequence where Element: ParseInstallation {
desires a different policy, it should be inserted in `options`.
*/
func createAllPublisher(batchLimit limit: Int? = nil,
transaction: Bool = ParseSwift.configuration.useTransactions,
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
options: API.Options = []) -> Future<[(Result<Self.Element, ParseError>)], ParseError> {
Future { promise in
self.createAll(batchLimit: limit,
Expand Down Expand Up @@ -227,7 +227,7 @@ public extension Sequence where Element: ParseInstallation {
desires a different policy, it should be inserted in `options`.
*/
func replaceAllPublisher(batchLimit limit: Int? = nil,
transaction: Bool = ParseSwift.configuration.useTransactions,
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
options: API.Options = []) -> Future<[(Result<Self.Element, ParseError>)], ParseError> {
Future { promise in
self.replaceAll(batchLimit: limit,
Expand Down Expand Up @@ -255,7 +255,7 @@ public extension Sequence where Element: ParseInstallation {
desires a different policy, it should be inserted in `options`.
*/
internal func updateAllPublisher(batchLimit limit: Int? = nil,
transaction: Bool = ParseSwift.configuration.useTransactions,
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
options: API.Options = []) -> Future<[(Result<Self.Element, ParseError>)],
ParseError> {
Future { promise in
Expand All @@ -282,7 +282,7 @@ public extension Sequence where Element: ParseInstallation {
the transactions can fail.
*/
func deleteAllPublisher(batchLimit limit: Int? = nil,
transaction: Bool = ParseSwift.configuration.useTransactions,
transaction: Bool = ParseSwift.configuration.isUsingTransactions,
options: API.Options = []) -> Future<[(Result<Void, ParseError>)], ParseError> {
Future { promise in
self.deleteAll(batchLimit: limit,
Expand Down
Loading

0 comments on commit 2ee5ab8

Please sign in to comment.