From eb5dbe2143a0c09cfdd4d1f156f059b01ac3e6b1 Mon Sep 17 00:00:00 2001 From: Ivan Vavilov Date: Thu, 12 Oct 2017 11:09:46 +0300 Subject: [PATCH] Fix relationship translation --- .../RealmDAO/Translator/RealmTranslator.swift | 12 +++++----- Example/DAO.xcodeproj/project.pbxproj | 22 ++++++++++++++++--- Example/Podfile.lock | 14 ++++++------ 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/DAO/Classes/RealmDAO/Translator/RealmTranslator.swift b/DAO/Classes/RealmDAO/Translator/RealmTranslator.swift index ec62f13..e302073 100644 --- a/DAO/Classes/RealmDAO/Translator/RealmTranslator.swift +++ b/DAO/Classes/RealmDAO/Translator/RealmTranslator.swift @@ -33,12 +33,12 @@ open class RealmTranslator { /// - entries: list of instances of `RealmModel` type. /// - fromEntities: array of instances of `Model` type. open func fill(_ entries: List, 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 { 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) } diff --git a/Example/DAO.xcodeproj/project.pbxproj b/Example/DAO.xcodeproj/project.pbxproj index 0347f4b..b86758b 100644 --- a/Example/DAO.xcodeproj/project.pbxproj +++ b/Example/DAO.xcodeproj/project.pbxproj @@ -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 */ = { diff --git a/Example/Podfile.lock b/Example/Podfile.lock index d135f5e..ad6c2b8 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -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