From 54cfaefd810ce7c8648d8a361834b460a3c01b0a Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 20 Aug 2017 15:03:05 -0700 Subject: [PATCH] =?UTF-8?q?Finish=20DatabaseLookupTable=20=E2=80=94=20well?= =?UTF-8?q?,=20except=20for=20testing=20and=20seeing=20if=20it=20actually?= =?UTF-8?q?=20works.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RSDatabase/RSDatabase/DatabaseLookupTable.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Frameworks/RSDatabase/RSDatabase/DatabaseLookupTable.swift b/Frameworks/RSDatabase/RSDatabase/DatabaseLookupTable.swift index eefb968f1..0dec93042 100644 --- a/Frameworks/RSDatabase/RSDatabase/DatabaseLookupTable.swift +++ b/Frameworks/RSDatabase/RSDatabase/DatabaseLookupTable.swift @@ -75,6 +75,8 @@ public final class DatabaseLookupTable { } } +// MARK: - Private + private extension DatabaseLookupTable { // MARK: Removing @@ -187,6 +189,10 @@ private extension DatabaseLookupTable { func saveLookups(for objectID: String, _ relatedObjectIDs: Set, _ database: FMDatabase) { + for relatedObjectID in relatedObjectIDs { + let d: [NSObject: Any] = [(objectIDKey as NSString): objectID, (relatedObjectIDKey as NSString): relatedObjectID] + let _ = database.rs_insertRow(with: d, insertType: .orIgnore, tableName: name) + } } // MARK: Attaching @@ -269,6 +275,8 @@ private extension DatabaseLookupTable { } } +// MARK: - + private struct LookupTable { private let dictionary: [String: Set] // objectID: Set