Closed omz13 closed 3 years ago
Hm. I would expect both to not allow matching directly between unit and int, because Go doesn't. It should use the same level of comparison that Go does. I'll look into it.
What is the type of Whatever.Key
in your example above? int or uint?
a uint64
So that is expected behavior per the documentation (https://github.com/timshannon/badgerhold#comparing). I tried the same scenario in bolthold, and the behavior is the same as expected.
Ah, mystery solved... but weird... I always thought when comparing with zero it was a case where no explicit casting was needed (since, zero is zero regardless of whether int or unit).
At compile time, that's true. Go can make assumptions and infer the type. At runtime that is not the case.
In bolthold, I used the following construction a few times to loop through all the records in the database :
Now, when I moved this over to badgerhold, it no longer worked (as in: no errors thrown and no records retrieved). The solution I discovered was that
.Ne(0)
needed to be replaced with.Ne(uint(0))
... so it seems that badgerhold, unlike bolthold, is a tad sensitive to int/uint?