Skip to content

CONTAINS in queries ignores key #2912

@feldgendler

Description

@feldgendler

Tendermint version: 0.22.8

The following patch adds a test that fails:

--- a/state/txindex/kv/kv_test.go
+++ b/state/txindex/kv/kv_test.go
@@ -89,6 +89,8 @@ func TestTxSearch(t *testing.T) {
                {"account.owner CONTAINS 'an'", 1},
                // search using CONTAINS
                {"account.owner CONTAINS 'Vlad'", 0},
+               // search for the wrong key using CONTAINS
+               {"account.number CONTAINS 'Iv'", 0},
        }

        for _, tc := range testCases {

This happens because match() in state/txindex/kv/kv.go performs a full scan and tests the value, but neglects to test the key.

The best way to fix is to do a prefix lookup on key/ instead of a full scan. It should also work faster.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C:rpcComponent: JSON RPC, gRPCT:bugType Bug (Confirmed)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions