ostafen / clover

A lightweight document-oriented NoSQL database written in pure Golang.
MIT License
666 stars 55 forks source link

V2: Sort() + Where() doesn't work #90

Closed axllent closed 2 years ago

axllent commented 2 years ago

With the first alpha release of v2, I have noticed that combining a Where() and a Sort() simply returns all results (Where() gets ignored?).

q, err := db.FindAll(clover.NewQuery(mailbox).
    Skip(start).
    Limit(limit).
    Sort(clover.SortOption{Field: "Created", Direction: -1}).
    Where(clover.Field("SearchText").Contains("my search text")))

If I skip the Sort() then the query works as expected (except the results are not sorted of course). "Created" is indexed in my case, and appears to work as expected with all other queries, just not when Where() is involved.

Any ideas?

ostafen commented 2 years ago

Hi, @axllent, thank you for reporting this. I just fixed the problem (it was due to a missing initialization statement) and I tagged the current commit as v2.0.0-alpha.1. I think you should update your modules. Can you check if it works?

axllent commented 2 years ago

Hi @ostafen, thanks, but I cannot for the life of me get Go to recognize that you have re-tagged v2.0.0-alpha.1 with a different commit. I've tried go get -u, go get -u -d github.com/ostafen/clover/v2@v2.0.0-alpha.1 and some other things, and tried that after manually deleting all my cached go modules - nothing seems to recognize that the tag commit has changed, and my go.mod remains unchanged. I guess the original v2.0.0-alpha.1 is cached somewhere (ie: where go really gets its code from, ie: not github).

Any suggestions?

ostafen commented 2 years ago

I think it is github which is linking the tag with the old commit yet, since I also have this problem. I have changed the tag of the current commit to v2.0.0-alpha.2. It should work now :=)

axllent commented 2 years ago

Awesome, my mod updated now to the v2.0.0-alpha.2 tag successfully - which also fixes the issue, thanks @ostafen !