mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-28 04:11:18 +01:00
WIP: clauses unit tests
This commit is contained in:
@@ -60,7 +60,7 @@ import CoreData
|
||||
- a version appears twice as a key in a dictionary literal
|
||||
- a loop is found in any of the paths
|
||||
*/
|
||||
public struct MigrationChain: NilLiteralConvertible, StringLiteralConvertible, DictionaryLiteralConvertible, ArrayLiteralConvertible {
|
||||
public struct MigrationChain: NilLiteralConvertible, StringLiteralConvertible, DictionaryLiteralConvertible, ArrayLiteralConvertible, Equatable {
|
||||
|
||||
/**
|
||||
Initializes the `MigrationChain` with empty values, which instructs the `DataStack` to use the .xcdatamodel's current version as the final version, and to disable progressive migrations.
|
||||
@@ -248,3 +248,16 @@ public struct MigrationChain: NilLiteralConvertible, StringLiteralConvertible, D
|
||||
|
||||
private let versionTree: [String: String]
|
||||
}
|
||||
|
||||
|
||||
// MARK: - MigrationChain: Equatable
|
||||
|
||||
@warn_unused_result
|
||||
public func == (lhs: MigrationChain, rhs: MigrationChain) -> Bool {
|
||||
|
||||
return lhs.versionTree == rhs.versionTree
|
||||
&& lhs.rootVersions == rhs.rootVersions
|
||||
&& lhs.leafVersions == rhs.leafVersions
|
||||
&& lhs.valid == rhs.valid
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +92,38 @@ public final class CSUnsafeDataTransaction: CSBaseDataTransaction {
|
||||
self.bridgeToSwift.redo()
|
||||
}
|
||||
|
||||
/**
|
||||
Immediately flushes all pending changes to the transaction's observers. This is useful in conjunction with `ListMonitor`s and `ObjectMonitor`s created from `UnsafeDataTransaction`s used to manage temporary "scratch" data.
|
||||
|
||||
- Important: Note that unlike `commit()`, `flush()` does not propagate/save updates to the `DataStack` and the persistent store. However, the flushed changes will be seen by children transactions created further from the current transaction (i.e. through `transaction.beginUnsafe()`)
|
||||
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
|
||||
*/
|
||||
@objc
|
||||
public func flush(error error: NSErrorPointer) {
|
||||
|
||||
bridge(error) {
|
||||
|
||||
try self.bridgeToSwift.flush()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Flushes all pending changes to the transaction's observers at the end of the `closure`'s execution. This is useful in conjunction with `ListMonitor`s and `ObjectMonitor`s created from `UnsafeDataTransaction`s used to manage temporary "scratch" data.
|
||||
|
||||
- Important: Note that unlike `commit()`, `flush()` does not propagate/save updates to the `DataStack` and the persistent store. However, the flushed changes will be seen by children transactions created further from the current transaction (i.e. through `transaction.beginUnsafe()`)
|
||||
- parameter error: the `NSError` pointer that indicates the reason in case of an failure
|
||||
- parameter closure: the closure where changes can be made prior to the flush
|
||||
*/
|
||||
@objc
|
||||
public func flush(error error: NSErrorPointer, block: () -> Void) throws {
|
||||
|
||||
bridge(error) {
|
||||
|
||||
block()
|
||||
try self.bridgeToSwift.context.save()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Begins a child transaction where `NSManagedObject` creates, updates, and deletes can be made. This is useful for making temporary changes, such as partially filled forms.
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public extension NSManagedObject {
|
||||
|
||||
When using an `UnsafeDataTransaction` and passing around a temporary object, you can use this property to execute fetches and updates to the transaction without having to pass around both the object and the transaction instances.
|
||||
|
||||
- Note: The internal reference to the transaction is `weak`, and it is still the developer's responsibility to retain a strong reference to the `UnsafeDataTransaction`.
|
||||
- Important: The internal reference to the transaction is `weak`, and it is still the developer's responsibility to retain a strong reference to the `UnsafeDataTransaction`.
|
||||
*/
|
||||
@nonobjc
|
||||
public var unsafeDataTransaction: UnsafeDataTransaction? {
|
||||
|
||||
Reference in New Issue
Block a user