Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @discardableResult to QueryBuilder's range and sort methods #592

Merged
merged 2 commits into from
Jan 31, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Sources/FluentKit/Query/Builder/QueryBuilder+Sort.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
extension QueryBuilder {
// MARK: Sort

@discardableResult
public func sort<Field>(
_ field: KeyPath<Model, Field>,
_ direction: DatabaseQuery.Sort.Direction = .ascending
Expand All @@ -12,6 +13,7 @@ extension QueryBuilder {
self.sort(Model.path(for: field), direction)
}

@discardableResult
public func sort<Field>(
_ field: KeyPath<Model, GroupPropertyPath<Model, Field>>,
_ direction: DatabaseQuery.Sort.Direction = .ascending
Expand All @@ -21,20 +23,23 @@ extension QueryBuilder {
self.sort(Model.path(for: field), direction)
}

@discardableResult
public func sort(
_ path: FieldKey,
_ direction: DatabaseQuery.Sort.Direction = .ascending
) -> Self {
self.sort([path], direction)
}

@discardableResult
public func sort(
_ path: [FieldKey],
_ direction: DatabaseQuery.Sort.Direction = .ascending
) -> Self {
self.sort(.extendedPath(path, schema: Model.schemaOrAlias, space: Model.spaceIfNotAliased), direction)
}

@discardableResult
public func sort<Joined, Field>(
_ joined: Joined.Type,
_ field: KeyPath<Joined, Field>,
Expand All @@ -49,6 +54,7 @@ extension QueryBuilder {
self.sort(Joined.self, Joined.path(for: field), direction, alias: alias)
}

@discardableResult
public func sort<Joined>(
_ model: Joined.Type,
_ path: FieldKey,
Expand All @@ -60,6 +66,7 @@ extension QueryBuilder {
self.sort(Joined.self, [path], direction)
}

@discardableResult
public func sort<Joined>(
_ model: Joined.Type,
_ path: [FieldKey],
Expand All @@ -71,6 +78,7 @@ extension QueryBuilder {
self.sort(.extendedPath(path, schema: Joined.schemaOrAlias, space: Joined.spaceIfNotAliased), direction)
}

@discardableResult
public func sort(
_ field: DatabaseQuery.Field,
_ direction: DatabaseQuery.Sort.Direction
Expand All @@ -79,6 +87,7 @@ extension QueryBuilder {
return self
}

@discardableResult
public func sort(_ sort: DatabaseQuery.Sort) -> Self {
self.query.sorts.append(sort)
return self
Expand Down
Loading