Comments (9)
Yeah that would work as a workaround, but I think I'm going to change the behavior to ensure a byte compare happens when using the bolthold.Key
field.
from bolthold.
That is interesting, and it looks like a bug. What UUID package are you using, and what encoding? My guess is that with Get
it's doing a strict byte comparison, where as Find attempts to make a comparison and may end up doing a UUID.String() comparison.
from bolthold.
Hi,
The UUID package is "github.com/google/uuid". I will try adding a Comparer to see if that helps.
Thanks,
from bolthold.
Sorry it's taken so long, but I finally found some time to look at this, and I'm having trouble replicating the issue.
Here's my attempt a repro which passes fine. I expected it to fail
func Test126FindOneVSGetOne(t *testing.T) {
testWrap(t, func(store *bolthold.Store, t *testing.T) {
type Test struct {
UUID uuid.UUID
}
id := uuid.New()
store.Upsert(id, Test{UUID: id})
result := Test{}
ok(t, store.FindOne(&result, bolthold.Where(bolthold.Key).Eq(id)))
equals(t, result.UUID, id)
result = Test{}
ok(t, store.Get(id, &result))
equals(t, result.UUID, id)
})
}
Could you show me how you are inserting the data and generating the UUID?
from bolthold.
Hi,
Thanks for Your time! I went on with using string instead of uuid.UUID as a workaround, but I am still curious what is going on here.
Your test works indeed, I have also tried to write my own reproducer so I can avoid the walk of shame comes with showing my real code, but I guess I can not help it.
These functions are for adding and getting a ShiftLogEntry:
https://git.sr.ht/~voroskoi/nRG/tree/ce0c37e08ab5f2ba6b62aa4c16cada480762e546/item/internal/db/sle.go
And these are the handler functions:
https://git.sr.ht/~voroskoi/nRG/tree/ce0c37e08ab5f2ba6b62aa4c16cada480762e546/item/internal/ui/sle.go
The error occurs on line 71. If I use the commented out line in SLEGet function it works, when I try using Get directly it does not.
Funny thing that after adding new entries getting them works for a while, but I have items that used to work, but now they do not. I have spent couple of hours to find out what happens, but I can not even reproduce it :-(
from bolthold.
So I may be wrong, as I've only done quick look through of your code, but I believe the issue is that you are defining your Key as a string here: https://git.sr.ht/~voroskoi/nRG/tree/master/item/models/shiftlog.go#L17
but trying to get it with a UUID type here: https://git.sr.ht/~voroskoi/nRG/tree/ce0c37e08ab5f2ba6b62aa4c16cada480762e546/item/internal/db/sle.go#L30
So the Find query just happens to work in this scenario because it's changing the UUID type to string because it can't find any other way to compare these two different types, and it works because you are actually storing the UUID as a string.
from bolthold.
No, it is not that. On Mar 18 I was at this state:
https://git.sr.ht/~voroskoi/nRG/tree/ce0c37e08ab5f2ba6b62aa4c16cada480762e546/item/models/shiftlog.go#L25
So You have mixed git HEAD
with ce0c37e08ab5f2ba6b62aa4c16cada480762e546
, I have switched to string with the next commit as I was unable to figure out what is going on.
from bolthold.
So once again, I can't replicate this issue myself. If you can get me a stand alone piece of code to replicate this, then I'll have something to fix, otherwise I don't see any issues here.
from bolthold.
I have written a minimal version of my program with inserting to the db and retrieving values via a http.Hander, but I was unable to reproduce this problem.
I think there are some other issue with the original code, which I can not reproduce and probably not related to bolthold.
from bolthold.
Related Issues (20)
- 如何查询某个bucket的全部数据 HOT 1
- his error occurs when fetching data from a specific bucket HOT 8
- readme.md: boltholdIndex, boltHoldIndex HOT 4
- Upsert with custom Storer delivers inconsistent value type to index function HOT 2
- Multiple calls to Delete for non-existing key result in EOF error instead of ErrNotFound HOT 2
- Add method to wrap existing bolt instance HOT 1
- Q: limit query without conditions HOT 2
- Unique index
- Can't sort by PK HOT 1
- Add support for batch inserts HOT 2
- Distinct constraint HOT 2
- Web UI
- Aggregate query on nested struct HOT 2
- Constraint pairs HOT 1
- Slow write speeds HOT 7
- Initialise read only store HOT 2
- foreach can't use, when the key's type is uint64 HOT 1
- SliceIndex query ContainsAll not working HOT 6
- Sort by primary key has no effect seemingly HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bolthold.