Skip to content

Commit

Permalink
Add select and disticnt builders to FetchSpecification
Browse files Browse the repository at this point in the history
... useful.
  • Loading branch information
helje5 committed Jan 1, 2025
1 parent 8fba63b commit 5cd4699
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Sources/ZeeQL/Control/FetchSpecification+Builder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -283,5 +288,19 @@ public extension DatabaseFetchSpecification
}
}

@inlinable
func select<each A: Attribute>(
_ attribute: repeat Swift.KeyPath<Object.FullEntity, each A>,
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)
}

0 comments on commit 5cd4699

Please sign in to comment.