Fix relationship translation

This commit is contained in:
Ivan Vavilov 2017-10-12 11:09:46 +03:00
parent 1fb6cb51fa
commit eb5dbe2143
3 changed files with 33 additions and 15 deletions

View File

@ -33,12 +33,12 @@ open class RealmTranslator<Model: Entity, RealmModel: RLMEntry> {
/// - entries: list of instances of `RealmModel` type.
/// - fromEntities: array of instances of `Model` type.
open func fill(_ entries: List<RealmModel>, fromEntities: [Model]) {
let oldEntries = entries.map { $0 }
entries.removeAll()
var newEntries = [RealmModel]()
fromEntities
.map { entity -> (RealmModel, Model) in
let entry = oldEntries
let entry = entries
.filter { $0.entryId == entity.entityId }
.first
@ -46,13 +46,15 @@ open class RealmTranslator<Model: Entity, RealmModel: RLMEntry> {
return (entry, entity)
} else {
let entry = RealmModel()
entries.append(entry)
newEntries.append(entry)
return (entry, entity)
}
}
.forEach {
self.fill($0.0, fromEntity: $0.1)
}
}
entries.append(objectsIn: newEntries)
}

View File

@ -493,13 +493,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-DAO_Example-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
525D7AFD3BD0F596CBD437B0 /* [CP] Copy Pods Resources */ = {
@ -538,13 +541,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-RealmDAOTests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
A3C342A12354181FB1CDC888 /* [CP] Embed Pods Frameworks */ = {
@ -553,9 +559,16 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-DAO_Example/Pods-DAO_Example-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/DAO/DAO.framework",
"${BUILT_PRODUCTS_DIR}/Realm/Realm.framework",
"${BUILT_PRODUCTS_DIR}/RealmSwift/RealmSwift.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DAO.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Realm.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RealmSwift.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@ -598,13 +611,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-CoreDataDAOTests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
FBB72B6CB6EF1FFF9E33FE93 /* [CP] Copy Pods Resources */ = {

View File

@ -1,9 +1,9 @@
PODS:
- DAO (1.0.0):
- DAO/CoreData (= 1.0.0)
- DAO/Realm (= 1.0.0)
- DAO/CoreData (1.0.0)
- DAO/Realm (1.0.0):
- DAO (1.0.3):
- DAO/CoreData (= 1.0.3)
- DAO/Realm (= 1.0.3)
- DAO/CoreData (1.0.3)
- DAO/Realm (1.0.3):
- RealmSwift
- Realm (2.8.1):
- Realm/Headers (= 2.8.1)
@ -19,10 +19,10 @@ EXTERNAL SOURCES:
:path: ../
SPEC CHECKSUMS:
DAO: 3e8e492bad862e8b804cd7d17dee0887658f5362
DAO: 375828ee8ea8d0479a2e094229ff9a353b7a8344
Realm: 2627602ad6818451f0cb8c2a6e072f7f10a5f360
RealmSwift: 4764ca7657f2193c256fb032c0b123926f70dbcd
PODFILE CHECKSUM: 304d7b9f54070467c355fe795db431630f017f61
COCOAPODS: 1.2.1
COCOAPODS: 1.3.1