Skip to content

Don't use transactions by default for internal SDK calls #158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# Parse-Swift Changelog

### main
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.8.0...main)
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.8.1...main)
* _Contributing to this repo? Add info about your change here to be included in the next release_

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ var score2ForFetchedLater: GameScore?
}

//: Saving multiple GameScores at once using a transaction.
[score, score2].saveAll(transaction: true) { results in
//: Currently doesn't work on mongo
/*[score, score2].saveAll(transaction: true) { results in
switch results {
case .success(let otherResults):
var index = 0
Expand All @@ -134,7 +135,7 @@ var score2ForFetchedLater: GameScore?
case .failure(let error):
assertionFailure("Error saving: \(error)")
}
}
}*/

//: Save synchronously (not preferred - all operations on main queue).
let savedScore: GameScore?
Expand Down Expand Up @@ -270,7 +271,7 @@ do {
}

//: Asynchronously (preferred way) deleteAll GameScores based on it's objectId alone.
[scoreToFetch, score2ToFetch].deleteAll(transaction: true) { result in
[scoreToFetch, score2ToFetch].deleteAll { result in
switch result {
case .success(let deletedScores):
deletedScores.forEach { result in
Expand Down
3 changes: 2 additions & 1 deletion ParseSwift.playground/Sources/Common.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ public func initializeParse() {
ParseSwift.initialize(applicationId: "applicationId",
clientKey: "clientKey",
masterKey: "masterKey",
serverURL: URL(string: "http://localhost:1337/1")!)
serverURL: URL(string: "http://localhost:1337/1")!,
useTransactionsInternally: false)
}

public func initializeParseCustomObjectId() {
Expand Down
2 changes: 1 addition & 1 deletion ParseSwift.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "ParseSwift"
s.version = "1.8.0"
s.version = "1.8.1"
s.summary = "Parse Pure Swift SDK"
s.homepage = "https://github.com/parse-community/Parse-Swift"
s.authors = {
Expand Down
16 changes: 8 additions & 8 deletions ParseSwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2425,7 +2425,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.8.0;
MARKETING_VERSION = 1.8.1;
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
PRODUCT_NAME = ParseSwift;
SKIP_INSTALL = YES;
Expand All @@ -2449,7 +2449,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.8.0;
MARKETING_VERSION = 1.8.1;
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
PRODUCT_NAME = ParseSwift;
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -2515,7 +2515,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 1.8.0;
MARKETING_VERSION = 1.8.1;
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
PRODUCT_NAME = ParseSwift;
SDKROOT = macosx;
Expand All @@ -2541,7 +2541,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 1.8.0;
MARKETING_VERSION = 1.8.1;
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
PRODUCT_NAME = ParseSwift;
SDKROOT = macosx;
Expand Down Expand Up @@ -2688,7 +2688,7 @@
INFOPLIST_FILE = "ParseSwift-watchOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.8.0;
MARKETING_VERSION = 1.8.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-watchOS";
Expand Down Expand Up @@ -2717,7 +2717,7 @@
INFOPLIST_FILE = "ParseSwift-watchOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.8.0;
MARKETING_VERSION = 1.8.1;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-watchOS";
PRODUCT_NAME = ParseSwift;
Expand All @@ -2744,7 +2744,7 @@
INFOPLIST_FILE = "ParseSwift-tvOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.8.0;
MARKETING_VERSION = 1.8.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-tvOS";
Expand Down Expand Up @@ -2772,7 +2772,7 @@
INFOPLIST_FILE = "ParseSwift-tvOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.8.0;
MARKETING_VERSION = 1.8.1;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-tvOS";
PRODUCT_NAME = ParseSwift;
Expand Down
2 changes: 1 addition & 1 deletion Scripts/jazzy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ bundle exec jazzy \
--author_url http://parseplatform.org \
--github_url https://github.com/parse-community/Parse-Swift \
--root-url http://parseplatform.org/Parse-Swift/api/ \
--module-version 1.8.0 \
--module-version 1.8.1 \
--theme fullwidth \
--skip-undocumented \
--output ./docs/api \
Expand Down
2 changes: 1 addition & 1 deletion Sources/ParseSwift/Objects/ParseObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ extension ParseObject {
// MARK: Savable Encodable Version
internal extension ParseType {
func saveAll(objects: [ParseType],
transaction: Bool = true,
transaction: Bool = ParseSwift.configuration.useTransactionsInternally,
options: API.Options = []) throws -> [(Result<PointerType, ParseError>)] {
try API.NonParseBodyCommand<AnyCodable, PointerType>
.batch(objects: objects,
Expand Down
10 changes: 10 additions & 0 deletions Sources/ParseSwift/Parse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public struct ParseConfiguration {
/// Allows objectIds to be created on the client.
var allowCustomObjectId = false

/// Use transactions inside the Client SDK.
/// - warning: This is experimental and known not to work with mongoDB.
var useTransactionsInternally = false

internal var authentication: ((URLAuthenticationChallenge,
(URLSession.AuthChallengeDisposition,
URLCredential?) -> Void) -> Void)?
Expand Down Expand Up @@ -57,6 +61,7 @@ public struct ParseConfiguration {
serverURL: URL,
liveQueryServerURL: URL? = nil,
allowCustomObjectId: Bool = false,
useTransactionsInternally: Bool = false,
keyValueStore: ParseKeyValueStore? = nil,
authentication: ((URLAuthenticationChallenge,
(URLSession.AuthChallengeDisposition,
Expand All @@ -67,6 +72,7 @@ public struct ParseConfiguration {
self.serverURL = serverURL
self.liveQuerysServerURL = liveQueryServerURL
self.allowCustomObjectId = allowCustomObjectId
self.useTransactionsInternally = useTransactionsInternally
self.mountPath = "/" + serverURL.pathComponents
.filter { $0 != "/" }
.joined(separator: "/")
Expand Down Expand Up @@ -153,6 +159,7 @@ public struct ParseSwift {
serverURL: URL,
liveQueryServerURL: URL? = nil,
allowCustomObjectId: Bool = false,
useTransactionsInternally: Bool = false,
keyValueStore: ParseKeyValueStore? = nil,
migrateFromObjcSDK: Bool = false,
authentication: ((URLAuthenticationChallenge,
Expand All @@ -165,6 +172,7 @@ public struct ParseSwift {
serverURL: serverURL,
liveQueryServerURL: liveQueryServerURL,
allowCustomObjectId: allowCustomObjectId,
useTransactionsInternally: useTransactionsInternally,
keyValueStore: keyValueStore,
authentication: authentication),
migrateFromObjcSDK: migrateFromObjcSDK)
Expand All @@ -176,6 +184,7 @@ public struct ParseSwift {
serverURL: URL,
liveQueryServerURL: URL? = nil,
allowCustomObjectId: Bool = false,
useTransactionsInternally: Bool = false,
keyValueStore: ParseKeyValueStore? = nil,
migrateFromObjcSDK: Bool = false,
testing: Bool = false,
Expand All @@ -188,6 +197,7 @@ public struct ParseSwift {
serverURL: serverURL,
liveQueryServerURL: liveQueryServerURL,
allowCustomObjectId: allowCustomObjectId,
useTransactionsInternally: useTransactionsInternally,
keyValueStore: keyValueStore,
authentication: authentication),
migrateFromObjcSDK: migrateFromObjcSDK)
Expand Down
2 changes: 1 addition & 1 deletion Sources/ParseSwift/ParseConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation

enum ParseConstants {
static let sdk = "swift"
static let version = "1.8.0"
static let version = "1.8.1"
static let hashingKey = "parseSwift"
static let fileManagementDirectory = "parse/"
static let fileManagementPrivateDocumentsDirectory = "Private Documents/"
Expand Down