Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
don't return false positives when searching for a prefix of a tag val…
Browse files Browse the repository at this point in the history
…ue (#2919)

Fixes #2908
  • Loading branch information
melekes authored and ebuchman committed Nov 27, 2018
1 parent bef39f3 commit 92dc5fc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ program](https://hackerone.com/tendermint).
- [blockchain] \#2731 Retry both blocks if either is bad to avoid getting stuck during fast sync (@goolAdapter)
- [log] \#2868 fix module=main setting overriding all others
- [rpc] \#2808 RPC validators calls IncrementAccum if necessary
- [kv indexer] \#2908 don't return false positives when searching for a prefix of a tag value
- [kv indexer] \#2775 order results by index if height is the same
- [rpc] \#2759 fix tx.height range queries
- [rpc] \#2811 Allow integer IDs in JSON-RPC requests
4 changes: 2 additions & 2 deletions state/txindex/kv/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,9 @@ LOOP:
func startKey(c query.Condition, height int64) []byte {
var key string
if height > 0 {
key = fmt.Sprintf("%s/%v/%d", c.Tag, c.Operand, height)
key = fmt.Sprintf("%s/%v/%d/", c.Tag, c.Operand, height)
} else {
key = fmt.Sprintf("%s/%v", c.Tag, c.Operand)
key = fmt.Sprintf("%s/%v/", c.Tag, c.Operand)
}
return []byte(key)
}
Expand Down
2 changes: 2 additions & 0 deletions state/txindex/kv/kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ func TestTxSearch(t *testing.T) {
{"account.number = 1 AND account.owner = 'Ivan'", 1},
// search by exact match (two tags)
{"account.number = 1 AND account.owner = 'Vlad'", 0},
// search using a prefix of the stored value
{"account.owner = 'Iv'", 0},
// search by range
{"account.number >= 1 AND account.number <= 5", 1},
// search by range (lower bound)
Expand Down

0 comments on commit 92dc5fc

Please sign in to comment.