Skip to content

Commit

Permalink
Enhance initializers of ModelFetchSpecification
Browse files Browse the repository at this point in the history
Allow for more things ...
  • Loading branch information
helje5 committed Nov 17, 2024
1 parent d19d830 commit 897a72f
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions Sources/ZeeQL/Control/ModelFetchSpecification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 }
Expand All @@ -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
Expand Down

0 comments on commit 897a72f

Please sign in to comment.