Skip to content

Commit 11a0e8a

Browse files
committed
Merge branch 'develop'
2 parents 2d5127d + 6fe6f77 commit 11a0e8a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1116
-525
lines changed

Sources/ZeeQL/Access/AccessDataSource.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// ZeeQL
44
//
55
// Created by Helge Hess on 24/02/17.
6-
// Copyright © 2017-2024 ZeeZide GmbH. All rights reserved.
6+
// Copyright © 2017-2026 ZeeZide GmbH. All rights reserved.
77
//
88

99
public protocol AccessDataSourceType: DataSourceType {
@@ -215,12 +215,12 @@ public extension AccessDataSourceType {
215215
// TBD: improve exception
216216
log.error("did not find entity, cannot construct fetchspec:",
217217
fetchSpecificationName)
218-
throw AccessDataSourceError.MissingEntity
218+
throw AccessDataSourceError.missingEntity
219219
}
220220

221221
guard let fs = findEntity[fetchSpecification: fetchSpecificationName] else {
222222
throw AccessDataSourceError
223-
.DidNotFindFetchSpecification(name: fetchSpecificationName,
223+
.didNotFindFetchSpecification(name: fetchSpecificationName,
224224
entity: findEntity)
225225
}
226226
return try fetchObjects(fs, binds, yield: yield)
@@ -331,7 +331,7 @@ public extension AccessDataSourceType {
331331
}
332332
else {
333333
throw AccessDataSourceError
334-
.CannotConstructFetchSpecification(.missingEntity)
334+
.cannotConstructFetchSpecification(.missingEntity)
335335
}
336336

337337
let qb = qualifierBindings

Sources/ZeeQL/Access/AccessDataSourceError.swift

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,27 @@
33
// ZeeQL
44
//
55
// Created by Helge Heß on 22.08.19.
6-
// Copyright © 2019-2024 ZeeZide GmbH. All rights reserved.
6+
// Copyright © 2019-2026 ZeeZide GmbH. All rights reserved.
77
//
88

99
public enum AccessDataSourceError: Swift.Error {
1010
// cannot nest in generic
1111

1212
public enum ConstructionErrorReason: Equatable {
13+
1314
case missingEntity
1415
case bindingFailed
1516
case invalidPrimaryKey
1617
}
1718

18-
case CannotConstructFetchSpecification(ConstructionErrorReason)
19-
case CannotConstructCountFetchSpecification
20-
case MissingEntity
21-
case CountFetchReturnedNoResults
22-
case FetchReturnedMoreThanOneResult(fetchSpecification: FetchSpecification,
19+
case cannotConstructFetchSpecification(ConstructionErrorReason)
20+
case cannotConstructCountFetchSpecification
21+
case missingEntity
22+
case countFetchReturnedNoResults
23+
case fetchReturnedMoreThanOneResult(fetchSpecification: FetchSpecification,
2324
firstObject: SwiftObject)
24-
25-
case DidNotFindFetchSpecification(name: String, entity: Entity)
26-
case CouldNotResolveBindings(fetchSpecification: FetchSpecification,
25+
26+
case didNotFindFetchSpecification(name: String, entity: Entity)
27+
case couldNotResolveBindings(fetchSpecification: FetchSpecification,
2728
bindings: Any)
2829
}

Sources/ZeeQL/Access/AccessDataSourceFinders.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// ZeeQL
44
//
55
// Created by Helge Heß on 22.08.19.
6-
// Copyright © 2019-2025 ZeeZide GmbH. All rights reserved.
6+
// Copyright © 2019-2026 ZeeZide GmbH. All rights reserved.
77
//
88

99
public extension AccessDataSource {
@@ -67,7 +67,7 @@ public extension AccessDataSource {
6767
func fetchObjectsFor(ids values: Any..., cb: ( Object ) -> Void) throws {
6868
guard let pkeys = entity?.primaryKeyAttributeNames, pkeys.count == 1 else {
6969
throw AccessDataSourceError
70-
.CannotConstructFetchSpecification(.invalidPrimaryKey)
70+
.cannotConstructFetchSpecification(.invalidPrimaryKey)
7171
}
7272

7373
try fetchObjectsFor(attribute: pkeys[0], with: values, cb: cb)
@@ -85,7 +85,7 @@ public extension AccessDataSource {
8585
func fetchObjectsFor(ids values: Any...) throws -> [ Object ] {
8686
guard let pkeys = entity?.primaryKeyAttributeNames, pkeys.count == 1 else {
8787
throw AccessDataSourceError
88-
.CannotConstructFetchSpecification(.invalidPrimaryKey)
88+
.cannotConstructFetchSpecification(.invalidPrimaryKey)
8989
}
9090

9191
var objects = [ Object ]()
@@ -117,7 +117,7 @@ public extension AccessDataSource { // GIDs
117117
//where S.Element : GlobalID
118118
where S.Element == KeyGlobalID
119119
{
120-
guard let entity = entity else { throw AccessDataSourceError.MissingEntity }
120+
guard let entity = entity else { throw AccessDataSourceError.missingEntity }
121121
let gidQualifiers = globalIDs.map { entity.qualifierForGlobalID($0) }
122122
let fs = ModelFetchSpecification(entity: entity,
123123
qualifier: gidQualifiers.or())
@@ -173,14 +173,14 @@ public extension AccessDataSource { // Finders
173173

174174
guard let findEntity = entity else {
175175
throw AccessDataSourceError
176-
.CannotConstructFetchSpecification(.missingEntity)
176+
.cannotConstructFetchSpecification(.missingEntity)
177177
}
178178

179179
guard let pkeys = findEntity.primaryKeyAttributeNames, !pkeys.isEmpty else{
180180
// TODO: hm, should we invoke a 'primary key find' policy here? (like
181181
// matching 'id' or 'tablename_id')
182182
throw AccessDataSourceError
183-
.CannotConstructFetchSpecification(.invalidPrimaryKey)
183+
.cannotConstructFetchSpecification(.invalidPrimaryKey)
184184
}
185185

186186
/* build qualifier for primary keys */
@@ -189,13 +189,13 @@ public extension AccessDataSource { // Finders
189189
// other keys
190190
let q : Qualifier
191191
if pkeys.count == 1 {
192-
let key = findEntity.keyForAttributeWith(name: pkeys[0])
192+
let key = findEntity.keyForAttributeWithName( pkeys[0])
193193
q = KeyValueQualifier(key, .equalTo, primaryKeyValues[0])
194194
}
195195
else {
196196
var qualifiers = [ Qualifier ]()
197197
for i in 0..<pkeys.count {
198-
let key = findEntity.keyForAttributeWith(name: pkeys[i])
198+
let key = findEntity.keyForAttributeWithName( pkeys[i])
199199
let q = KeyValueQualifier(key, .equalTo, primaryKeyValues[i])
200200
qualifiers.append(q)
201201
}
@@ -229,7 +229,7 @@ public extension AccessDataSource { // Finders
229229
try _primaryFetchObjects(fs) {
230230
guard object == nil else {
231231
throw AccessDataSourceError
232-
.FetchReturnedMoreThanOneResult(fetchSpecification: fs,
232+
.fetchReturnedMoreThanOneResult(fetchSpecification: fs,
233233
firstObject: object!)
234234
}
235235
object = $0

Sources/ZeeQL/Access/ActiveDataSource.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// ZeeQL
44
//
55
// Created by Helge Hess on 27/02/17.
6-
// Copyright © 2017-2024 ZeeZide GmbH. All rights reserved.
6+
// Copyright © 2017-2026 ZeeZide GmbH. All rights reserved.
77
//
88

99
public protocol ActiveDataSourceType<Object>: AccessDataSourceType
@@ -133,7 +133,7 @@ open class ActiveDataSource<Object: ActiveRecordType>: AccessDataSource<Object>,
133133
guard let pkeys = entity.primaryKeyAttributeNames, !pkeys.isEmpty else {
134134
globalZeeQLLogger.error("entity has no primary keys for gid fetch:",
135135
entity)
136-
throw AccessDataSourceError.MissingEntity
136+
throw AccessDataSourceError.missingEntity
137137
}
138138

139139
var cfs = fs
@@ -171,7 +171,7 @@ open class ActiveDataSource<Object: ActiveRecordType>: AccessDataSource<Object>,
171171
// required as we pass in the attributes to selectExpressionForAttrs...?
172172
// Hm.
173173
guard let cfs = fs.fetchSpecificationForCount else {
174-
throw AccessDataSourceError.CannotConstructCountFetchSpecification
174+
throw AccessDataSourceError.cannotConstructCountFetchSpecification
175175
}
176176
#else
177177
// The idea is that this preserves the WHERE part of the query, including
@@ -213,7 +213,7 @@ open class ActiveDataSource<Object: ActiveRecordType>: AccessDataSource<Object>,
213213
}
214214

215215
guard let result = fetchCount else {
216-
throw AccessDataSourceError.CountFetchReturnedNoResults
216+
throw AccessDataSourceError.countFetchReturnedNoResults
217217
}
218218

219219
return result

Sources/ZeeQL/Access/ActiveRecord.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// ZeeQL
44
//
55
// Created by Helge Hess on 26/02/2017.
6-
// Copyright © 2017-2025 ZeeZide GmbH. All rights reserved.
6+
// Copyright © 2017-2026 ZeeZide GmbH. All rights reserved.
77
//
88

99
/**
@@ -141,7 +141,7 @@ open class ActiveRecordBase : ActiveRecordType, SmartDescription {
141141
}
142142
}
143143

144-
open func value(forKey k: String) -> Any? { // dupe for protocol override
144+
open func valueForKey(_ k: String) -> Any? { // dupe for protocol override
145145
willRead()
146146

147147
// first check extra properties
@@ -150,18 +150,18 @@ open class ActiveRecordBase : ActiveRecordType, SmartDescription {
150150
}
151151

152152
// then fallback to KVC
153-
if let v = KeyValueCoding.defaultValue(forKey: k, inObject: self) {
153+
if let v = KeyValueCoding.defaultValueForKey(k, inObject: self) {
154154
return v
155155
}
156156

157157
return nil
158158
}
159159

160160

161-
open func storedValue(forKey k: String) -> Any? {
161+
open func storedValueForKey(_ k: String) -> Any? {
162162
willRead()
163-
164-
if let v = value(forKey: k) { return v } // ask regular KVC
163+
164+
if let v = valueForKey(k) { return v } // ask regular KVC
165165
if let v = values[k] { return v }
166166
return nil
167167
}
@@ -183,7 +183,7 @@ open class ActiveRecordBase : ActiveRecordType, SmartDescription {
183183

184184
// TBD: Really AnyObject? Rather `DatabaseObject`?
185185
// Because the input is like that!
186-
if var list = storedValue(forKey: key) as? [ AnyObject ] {
186+
if var list = storedValueForKey(key) as? [ AnyObject ] {
187187
if !list.contains(where: { $0 === object }) {
188188
list.append(object)
189189
takeStoredValue(list, forKey: key)
@@ -202,7 +202,7 @@ open class ActiveRecordBase : ActiveRecordType, SmartDescription {
202202
return
203203
}
204204

205-
guard var list = storedValue(forKey: key) as? [ AnyObject ] else { return }
205+
guard var list = storedValueForKey(key) as? [ AnyObject ] else { return }
206206
guard let idx = list.firstIndex(where: { $0 === o }) else { return }
207207

208208
list.remove(at: idx)
@@ -213,7 +213,7 @@ open class ActiveRecordBase : ActiveRecordType, SmartDescription {
213213
// MARK: - Save
214214

215215
open func validateForSave() throws {
216-
guard !isReadOnly else { throw DatabaseObjectError.ReadOnly(self) }
216+
guard !isReadOnly else { throw DatabaseObjectError.readOnly(self) }
217217
}
218218

219219
open func save() throws {
@@ -222,7 +222,7 @@ open class ActiveRecordBase : ActiveRecordType, SmartDescription {
222222
* about us and lets us do the work.
223223
*/
224224
guard let db = lookupDatabase() else {
225-
throw DatabaseObjectError.NoDatabase(self)
225+
throw DatabaseObjectError.noDatabase(self)
226226
}
227227

228228
/* validate and create database operation */
@@ -266,7 +266,7 @@ open class ActiveRecordBase : ActiveRecordType, SmartDescription {
266266
guard !isNew else { return } /* nothing to be done in the DB */
267267

268268
guard let db = lookupDatabase() else {
269-
throw DatabaseObjectError.NoDatabase(self)
269+
throw DatabaseObjectError.noDatabase(self)
270270
}
271271

272272
/* create database operation */
@@ -399,7 +399,7 @@ open class ActiveRecordBase : ActiveRecordType, SmartDescription {
399399
assertionFailure("failed to take value for dynamic member: \(member)")
400400
}
401401
}
402-
get { return value(forKey: member) }
402+
get { return valueForKey(member) }
403403
}
404404
}
405405
#else

Sources/ZeeQL/Access/ActiveRecordType.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// ZeeQL3
44
//
55
// Created by Helge Heß on 03.09.19.
6-
// Copyright © 2019 ZeeZide GmbH. All rights reserved.
6+
// Copyright © 2019-2026 ZeeZide GmbH. All rights reserved.
77
//
88

99
/**
@@ -48,12 +48,13 @@ public protocol DatabaseBoundObject {
4848

4949
public extension ActiveRecordType { // default imp
5050

51-
func value(forKey k: String) -> Any? {
51+
@inlinable
52+
func valueForKey(_ k: String) -> Any? {
5253
// first check extra properties
5354
if let v = values[k] { return v }
5455

5556
// then fallback to KVC
56-
if let v = KeyValueCoding.defaultValue(forKey: k, inObject: self) {
57+
if let v = KeyValueCoding.defaultValueForKey(k, inObject: self) {
5758
return v
5859
}
5960

@@ -79,7 +80,7 @@ public extension ActiveRecordType { // default imp
7980
}
8081
}
8182
get {
82-
return value(forKey: key)
83+
return valueForKey(key)
8384
}
8485
}
8586

Sources/ZeeQL/Access/AdaptorChannel.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// ZeeQL
44
//
55
// Created by Helge Hess on 24/02/17.
6-
// Copyright © 2017-2025 ZeeZide GmbH. All rights reserved.
6+
// Copyright © 2017-2026 ZeeZide GmbH. All rights reserved.
77
//
88

99
/**
@@ -264,7 +264,7 @@ public extension AdaptorChannel {
264264

265265
case .insert:
266266
guard let values = op.changedValues else {
267-
throw AdaptorChannelError.MissingRecordToInsert
267+
throw AdaptorChannelError.missingRecordToInsert
268268
}
269269

270270
// Note: we trigger a full refetch
@@ -275,24 +275,24 @@ public extension AdaptorChannel {
275275

276276
case .update:
277277
guard let values = op.changedValues else {
278-
throw AdaptorChannelError.MissingRecordToUpdate
278+
throw AdaptorChannelError.missingRecordToUpdate
279279
}
280280
guard let q = op.qualifier else {
281-
throw AdaptorChannelError.MissingQualification
281+
throw AdaptorChannelError.missingQualification
282282
}
283283

284284
affectedRows = try updateValuesInRowsDescribedByQualifier(values,
285285
q, op.entity)
286286

287287
case .delete:
288288
guard let q = op.qualifier else {
289-
throw AdaptorChannelError.MissingQualification
289+
throw AdaptorChannelError.missingQualification
290290
}
291291

292292
affectedRows = try deleteRowsDescribedByQualifier(q, op.entity)
293293

294294
case .none:
295-
throw AdaptorChannelError.UnexpectedOperation
295+
throw AdaptorChannelError.unexpectedOperation
296296
}
297297

298298
return affectedRows
@@ -568,7 +568,7 @@ public extension AdaptorChannel { // MARK: - Operations
568568

569569
// Perform the INSERT
570570
guard try evaluateUpdateExpression(expr) == 1 else {
571-
throw AdaptorError.OperationDidNotAffectOne
571+
throw AdaptorError.operationDidNotAffectOne
572572
}
573573

574574
// TODO: We need to refetch the pkey if it is auto-increment?! This just
@@ -584,7 +584,7 @@ public extension AdaptorChannel { // MARK: - Operations
584584
return refetchAll ? row : pkey
585585
}
586586

587-
throw AdaptorError.FailedToGrabNewPrimaryKey(entity: entity, row: row)
587+
throw AdaptorError.failedToGrabNewPrimaryKey(entity: entity, row: row)
588588
}
589589

590590
/**
@@ -681,7 +681,7 @@ public extension AdaptorChannel {
681681

682682
for table in tableNames {
683683
guard let entity = try describeEntityWithTableName(table) else {
684-
throw AdaptorChannelError.CouldNotDescribeTable(table)
684+
throw AdaptorChannelError.couldNotDescribeTable(table)
685685
}
686686

687687
entities.append(entity)

0 commit comments

Comments
 (0)