Hi folks. I just found a bug i my exposed DAO code. The following code returned incorrect value (testing against object instance) collection member :
val existingVote = this.votes.firstOrNull { vote -> vote.votedBy == voter }
This was fixed by testing against id's :
val existingVote = this.votes.firstOrNull { vote -> vote.votedBy.id == voter.id }
Why can't I trust testing against object instance ? Shouldnt this be referenced somewhere in the documentation ? Why exposed library doesn't provide a comparison overload operator to compare two IntEntity object ?
(this was tested with 0.17.4)
Edit again :
If i make my class inherit of this class below, this fix my problem ...
open class MyIntEntity(id: EntityID<Int>) : IntEntity(id)
{
override fun equals(other: Any?): Boolean {
if (other !is IntEntity) return false
return other.id == this.id
}
}
I believe this is because separate instance object have been created by two different transactions ... anyway, it should make sense to expect that such object are somehow the same because they have the same id's ?
What do you thing ? Did I found a bug ? Where should I report it ?
Last edit ( 😉 ) : I made a sample project to show-case the problem :
https://gitlab.com/jfburdet/tstexposed/blob/master/test/kotlin/ComparisonTest.kt ... feel free to clone it and have a look