Skip to content

Commit

Permalink
Multi-value typed order
Browse files Browse the repository at this point in the history
Using parameter packs, yay! :-)
  • Loading branch information
helje5 committed Dec 4, 2024
1 parent d809254 commit 9e5385f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Sources/ZeeQL/Control/FetchSpecification+Builder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,22 @@ public extension DatabaseFetchSpecification
let so = SortOrdering(key: AttributeKey(attribute), selector: selector)
return order(by: so)
}

#if swift(>=5.9)
@inlinable
func order<each V: AttributeValue>(
by key: repeat Swift.KeyPath<Object.FullEntity, CodeAttribute<each V>>,
using selector: SortOrdering.Selector = .CompareAscending
) -> Self
{
var fs = self
for key in repeat each key {
let attribute = Object.e[keyPath: key]
let so = SortOrdering(key: AttributeKey(attribute), selector: selector)
if fs.sortOrderings == nil { fs.sortOrderings = [ so ] }
else { fs.sortOrderings?.append(so) }
}
return fs
}
#endif // swift(>=5.9
}

0 comments on commit 9e5385f

Please sign in to comment.