mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-12 12:20:30 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1950224863 | ||
|
|
f0cd288657 | ||
|
|
3344e42d7c | ||
|
|
e4b6c06401 |
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "CoreStore"
|
||||
s.version = "2.0.1"
|
||||
s.version = "2.0.3"
|
||||
s.license = "MIT"
|
||||
s.summary = "Unleashing the real power of Core Data with the elegance and safety of Swift"
|
||||
s.homepage = "https://github.com/JohnEstropia/CoreStore"
|
||||
|
||||
@@ -147,7 +147,7 @@ final class ErrorTests: XCTestCase {
|
||||
"key3": NSDate()
|
||||
]
|
||||
)
|
||||
let error = CoreStoreError.InternalError(NSError: internalError)
|
||||
let error = CoreStoreError(internalError)
|
||||
XCTAssertEqual((error as NSError).domain, CoreStoreErrorDomain)
|
||||
XCTAssertEqual((error as NSError).code, CoreStoreErrorCode.InternalError.rawValue)
|
||||
|
||||
|
||||
@@ -715,9 +715,28 @@ internal extension CollectionType where Generator.Element == SelectTerm {
|
||||
fetchRequest.includesPendingChanges = false
|
||||
fetchRequest.resultType = .DictionaryResultType
|
||||
|
||||
let entityDescription = fetchRequest.entity!
|
||||
let propertiesByName = entityDescription.propertiesByName
|
||||
let attributesByName = entityDescription.attributesByName
|
||||
func attributeDescriptionForKeyPath(keyPath: String, inEntity entity: NSEntityDescription) -> NSAttributeDescription? {
|
||||
|
||||
let components = keyPath.componentsSeparatedByString(".")
|
||||
switch components.count {
|
||||
|
||||
case 0:
|
||||
return nil
|
||||
|
||||
case 1:
|
||||
return entity.attributesByName[components[0]]
|
||||
|
||||
default:
|
||||
guard let relationship = entity.relationshipsByName[components[0]] else {
|
||||
|
||||
return nil
|
||||
}
|
||||
return attributeDescriptionForKeyPath(
|
||||
components.dropFirst().joinWithSeparator("."),
|
||||
inEntity: relationship.entity
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
var propertiesToFetch = [AnyObject]()
|
||||
for term in self {
|
||||
@@ -725,20 +744,22 @@ internal extension CollectionType where Generator.Element == SelectTerm {
|
||||
switch term {
|
||||
|
||||
case ._Attribute(let keyPath):
|
||||
if let propertyDescription = propertiesByName[keyPath] {
|
||||
let entityDescription = fetchRequest.entity!
|
||||
if let attributeDescription = attributeDescriptionForKeyPath(keyPath, inEntity: entityDescription) {
|
||||
|
||||
propertiesToFetch.append(propertyDescription)
|
||||
propertiesToFetch.append(attributeDescription)
|
||||
}
|
||||
else {
|
||||
|
||||
CoreStore.log(
|
||||
.Warning,
|
||||
message: "The property \"\(keyPath)\" does not exist in entity \(cs_typeName(entityDescription.managedObjectClassName)) and will be ignored by \(cs_typeName(owner)) query clause."
|
||||
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."
|
||||
)
|
||||
}
|
||||
|
||||
case ._Aggregate(let function, let keyPath, let alias, let nativeType):
|
||||
if let attributeDescription = attributesByName[keyPath] {
|
||||
let entityDescription = fetchRequest.entity!
|
||||
if let attributeDescription = attributeDescriptionForKeyPath(keyPath, inEntity: entityDescription) {
|
||||
|
||||
let expressionDescription = NSExpressionDescription()
|
||||
expressionDescription.name = alias
|
||||
@@ -754,14 +775,13 @@ internal extension CollectionType where Generator.Element == SelectTerm {
|
||||
forFunction: function,
|
||||
arguments: [NSExpression(forKeyPath: keyPath)]
|
||||
)
|
||||
|
||||
propertiesToFetch.append(expressionDescription)
|
||||
}
|
||||
else {
|
||||
|
||||
CoreStore.log(
|
||||
.Warning,
|
||||
message: "The attribute \"\(keyPath)\" does not exist in entity \(cs_typeName(entityDescription.managedObjectClassName)) and will be ignored by \(cs_typeName(owner)) query clause."
|
||||
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."
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.0.1</string>
|
||||
<string>2.0.3</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@@ -248,9 +248,17 @@ internal extension ErrorType {
|
||||
|
||||
switch self {
|
||||
|
||||
case let error as CoreStoreError: return error
|
||||
case let error as CSError: return error.bridgeToSwift
|
||||
default: return .Unknown
|
||||
case let error as CoreStoreError:
|
||||
return error
|
||||
|
||||
case let error as CSError:
|
||||
return error.bridgeToSwift
|
||||
|
||||
case let error as NSError where self.dynamicType is NSError.Type:
|
||||
return .InternalError(NSError: error)
|
||||
|
||||
default:
|
||||
return .Unknown
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,9 +266,14 @@ internal extension ErrorType {
|
||||
|
||||
switch self {
|
||||
|
||||
case let error as CoreStoreError: return error.bridgeToObjectiveC
|
||||
case let error as CSError: return error
|
||||
default: return self as NSError
|
||||
case let error as CoreStoreError:
|
||||
return error.bridgeToObjectiveC
|
||||
|
||||
case let error as CSError:
|
||||
return error
|
||||
|
||||
default:
|
||||
return self as NSError
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user