Hi, Thank you for creating Exposed, I'm having a g...
# exposed
t
Hi, Thank you for creating Exposed, I'm having a great time learning the library 🙂 I was just wondering if it would be a good idea to change the
adjustSlice
function from
Copy code
fun adjustSlice(body: ColumnSet.() -> FieldSet): Query = apply { set = set.source.body() }
to something like
Copy code
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:
Copy code
fun Query.addToSlice(vararg columns: Expression<*>): Query {
    return adjustSlice {
        slice(this@addToSlice.set.fields + columns)
    }
}
t
Sound reasonable enougth. I'll extend
adjustSlice
on the next minor release.
t
🤩