Tobias G. Waaler
08/06/2020, 6:27 PMadjustSlice
function from
fun adjustSlice(body: ColumnSet.() -> FieldSet): Query = apply { set = set.source.body() }
to something like
fun adjustSlice(body: ColumnSet.(FieldSet) -> FieldSet): Query = apply { set = set.source.body(set) }
That way you can get a hold of fields that are currently a part of the fieldset for the query and do things like adding additional fields (or even removing fields).
To me this was useful when I wanted to add a single extra field to the slice, depending on some condition. Currently I've created this extension function that I'm using, and it works quite well:
fun Query.addToSlice(vararg columns: Expression<*>): Query {
return adjustSlice {
slice(this@addToSlice.set.fields + columns)
}
}
tapac
08/07/2020, 3:22 PMadjustSlice
on the next minor release.Tobias G. Waaler
08/07/2020, 6:57 PM