Closed janheinrichmerker closed 5 years ago
After some quick testing I found out, returning a RangeQueryBuilder
in the contains
is not allowed, as it must return Boolean
.
However, we can still use the range operators and define an infix function:
infix fun String.inRange(range: ClosedRange<Int>): RangeQueryBuilder =
RangeQueryBuilder(this).from(range.start).to(range.endInclusive)
Then we can instead use:
"age" inRange 10..20
Regarding optional parameters of RangeQueryBuilder
, we might as well offer configuration like this:
"objj" inRange (5..78) {
includeLower = true
includeUpper = false
}
(Of course this might be a separate issue then.)
Instead of constructing simple range queries like this:
we should leverage the Kotlin range operator (
..
) and overload thein
-operator operator to construct the same query like this:We then need to override the following function:
Similar methods could be added for other number types.
Additional consideration has to be done about non-inclusive floating point ranges, to support
include_lower
/include_upper
. Same goes for the other optional parameters ofRangeQueryBuilder
.