From f436b26e8e73613e3d959b7e3ebb570b9e87dc20 Mon Sep 17 00:00:00 2001 From: John Rommel Estropia Date: Fri, 8 Sep 2017 01:28:24 +0900 Subject: [PATCH] allow compound keypaths in Select terms --- Sources/Select.swift | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/Sources/Select.swift b/Sources/Select.swift index 6b2e8c4..e5bc20a 100644 --- a/Sources/Select.swift +++ b/Sources/Select.swift @@ -401,13 +401,14 @@ internal extension Collection where Iterator.Element == SelectTerm { return entity.attributesByName[components[0]] default: - guard let relationship = entity.relationshipsByName[components[0]] else { - - return nil + guard let relationship = entity.relationshipsByName[components[0]], + let destinationEntity = relationship.destinationEntity else { + + return nil } return attributeDescription( for: components.dropFirst().joined(separator: "."), - in: relationship.entity + in: destinationEntity ) } } @@ -418,18 +419,7 @@ internal extension Collection where Iterator.Element == SelectTerm { switch term { case ._attribute(let keyPath): - let entityDescription = fetchRequest.entity! - if let attributeDescription = attributeDescription(for: keyPath, in: entityDescription) { - - propertiesToFetch.append(attributeDescription) - } - else { - - CoreStore.log( - .warning, - message: "The key path \"\(keyPath)\" could not be resolved in entity \(cs_typeName(entityDescription.managedObjectClassName)) as an attribute and will be ignored by \(cs_typeName(owner)) query clause." - ) - } + propertiesToFetch.append(keyPath) case ._aggregate(let function, let keyPath, let alias, let nativeType): let entityDescription = fetchRequest.entity!