Replies: 1 comment 1 reply
-
Hi @pfandrade, I'm not sure we will be able to add this functionality to But what you want can be done quite simply already. You can define helpers for your expressions on extension WishedItem.TableColumns {
var discountAmount: some QueryExpression<Double?> {
#sql("(\(lastKnownPrice) - \(originalPrice))")
}
var discountPercentage: some QueryExpression<Double?> {
#sql("(1-(\(lastKnownPrice) / \(originalPrice)))"))
}
} And then sorting is as simple as this: WishedItem.notDeleted
.where { $0.wishlistID.eq(id) }
.select {
ListFeature.WishedItemEntry.Columns(
item: $0,
discountAmount: $0.discountAmount,
discountPercentage: $0.discountPercentage
)
}
.order(by: \.discountAmount) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Being able to issue queries returning a custom struct suitable for the current view is super nice. But it would be even nicer if we could use that new
@Selection
struct's columns in the ORDER BY expression.For example, given this selection:
And the following query:
It's not possible to order the results based on the columns of the
WishedItemEntry
. This is a powerful feature in SQL and it would be really nice to be able to write using the SQL builder syntax.Beta Was this translation helpful? Give feedback.
All reactions