having a class such as (this is kotlin
, but the code is very understandable):
@Repository
interface ScoresRepository : MongoRepository<Score, String> {
fun countAllByScoreIsBetween(min: Int, max: Int): Int
}
@Document
data class Score(
@Id var score: Int,
)
Is the between inclusive or exclusive? That is, if I have scores 1-10, and I called: countAllByScoreIsBetween(3,6)
would I get 4 or 2? or maybe something else - bottom is inclusive and top is exclusive?
Tests (with testcontainers
) show this:
@Autowired
lateinit var scoresRepository: ScoresRepository
@Test
fun test() {
for (i in 1..10) {
scoresRepository.save(Score(score = i))
}
val count = scoresRepository.countAllByScoreIsBetween(3, 6)
assertThat(count).isEqualTo(2)
}
So as far as I see, both params are not included. That is, Between
means everything between the values, not including the values themselves.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments