From 897a72fc81c1c0f1433c56aef4665947c8957804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helge=20He=C3=9F?= Date: Sun, 17 Nov 2024 16:22:43 +0100 Subject: [PATCH] Enhance initializers of `ModelFetchSpecification` Allow for more things ... --- .../Control/ModelFetchSpecification.swift | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/Sources/ZeeQL/Control/ModelFetchSpecification.swift b/Sources/ZeeQL/Control/ModelFetchSpecification.swift index 7b6d3e4..659d0fc 100644 --- a/Sources/ZeeQL/Control/ModelFetchSpecification.swift +++ b/Sources/ZeeQL/Control/ModelFetchSpecification.swift @@ -3,7 +3,7 @@ // ZeeQL // // Created by Helge Hess on 06/03/17. -// Copyright © 2017 ZeeZide GmbH. All rights reserved. +// Copyright © 2017-2024 ZeeZide GmbH. All rights reserved. // public struct ModelFetchSpecification : FetchSpecification { @@ -13,6 +13,7 @@ public struct ModelFetchSpecification : FetchSpecification { public var entity : Entity? public var _entityName : String? + @inlinable public var entityName : String? { if let e = entity { return e.name } if let n = _entityName { return n } @@ -31,43 +32,67 @@ public struct ModelFetchSpecification : FetchSpecification { public var deep = false public var fetchesRawRows = false public var fetchesReadOnly = false - public var requiresAllQualifierBindingVariables = false + public var requiresAllQualifierBindingVariables = false // TBD: why false? public var prefetchingRelationshipKeyPathes : [ String ]? + @inlinable public init(entityName : String? = nil, qualifier : Qualifier? = nil, sortOrderings : [ SortOrdering ]? = nil, - limit : Int? = nil) + offset : Int? = nil, + limit : Int? = nil, + prefetch : [ String ]? = nil, + requiresAllQualifierBindingVariables: Bool = false) { self._entityName = entityName self.qualifier = qualifier self.sortOrderings = sortOrderings + self.fetchOffset = offset self.fetchLimit = limit + self.prefetchingRelationshipKeyPathes = prefetch + self.requiresAllQualifierBindingVariables = + requiresAllQualifierBindingVariables } + + @inlinable public init(entity : Entity, qualifier : Qualifier? = nil, sortOrderings : [ SortOrdering ]? = nil, - limit : Int? = nil) + offset : Int? = nil, + limit : Int? = nil, + prefetch : [ String ]? = nil, + requiresAllQualifierBindingVariables: Bool = false) { self.entity = entity self.qualifier = qualifier self.sortOrderings = sortOrderings + self.fetchOffset = offset self.fetchLimit = limit + self.prefetchingRelationshipKeyPathes = prefetch + self.requiresAllQualifierBindingVariables = + requiresAllQualifierBindingVariables } + @inlinable public init(entity : Entity, _ q : String, sortOrderings : [ SortOrdering ]? = nil, + offset : Int? = nil, limit : Int? = nil, - prefetch : [ String ]? = nil) + prefetch : [ String ]? = nil, + requiresAllQualifierBindingVariables: Bool = false) { self.entity = entity self.qualifier = qualifierWith(format: q) self.sortOrderings = sortOrderings + self.fetchOffset = offset self.fetchLimit = limit self.prefetchingRelationshipKeyPathes = prefetch + self.requiresAllQualifierBindingVariables = + requiresAllQualifierBindingVariables } + @inlinable public init(fetchSpecification fs: FetchSpecification) { entity = fs.entity fetchAttributeNames = fs.fetchAttributeNames