From 5cd4699176177103c7c13675d7f0b016da42d4da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helge=20He=C3=9F?= Date: Wed, 1 Jan 2025 18:27:30 +0100 Subject: [PATCH] Add `select` and `disticnt` builders to `FetchSpecification` ... useful. --- .../Control/FetchSpecification+Builder.swift | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Sources/ZeeQL/Control/FetchSpecification+Builder.swift b/Sources/ZeeQL/Control/FetchSpecification+Builder.swift index de21b90..aa5dbdc 100644 --- a/Sources/ZeeQL/Control/FetchSpecification+Builder.swift +++ b/Sources/ZeeQL/Control/FetchSpecification+Builder.swift @@ -83,6 +83,11 @@ public extension FetchSpecification { @inlinable func offset(_ value : Int) -> Self { transform { $0.fetchOffset = value } } + @inlinable + func distinct(_ usesDistinct: Bool = true) -> Self { + transform { $0.usesDistinct = usesDistinct } + } + // MARK: - Prefetches @@ -283,5 +288,19 @@ public extension DatabaseFetchSpecification } } + @inlinable + func select( + _ attribute: repeat Swift.KeyPath, + clear: Bool = false + ) -> Self + { + transform { + if clear { $0.fetchAttributeNames = [] } + for attributePath in repeat each attribute { + let attribute = Object.e[keyPath: attributePath] + $0.fetchAttributeNames.append(attribute.name) + } + } + } #endif // compiler(>=6) }