diff --git a/platform/common/core/generic/vault/txidstore/simpletxidstore_test.go b/platform/common/core/generic/vault/txidstore/simpletxidstore_test.go index df60650ee..227de9e9a 100644 --- a/platform/common/core/generic/vault/txidstore/simpletxidstore_test.go +++ b/platform/common/core/generic/vault/txidstore/simpletxidstore_test.go @@ -323,5 +323,7 @@ func testTXIDStore(t *testing.T, store *SimpleTXIDStore[vc]) { txids[i] = result.TxID } assert.Len(t, txids, 2) - assert.Equal(t, []string{"txid1025", "txid21"}, txids) + assert.Contains(t, txids, "txid21") + assert.Contains(t, txids, "txid1025") + } diff --git a/platform/view/services/db/driver/sql/postgres/conditions.go b/platform/view/services/db/driver/sql/postgres/conditions.go index 77750f3ed..7b5c67c40 100644 --- a/platform/view/services/db/driver/sql/postgres/conditions.go +++ b/platform/view/services/db/driver/sql/postgres/conditions.go @@ -10,6 +10,46 @@ import ( "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/db/driver/sql/common" ) -func NewInterpreter() common.Interpreter { - return common.NewInterpreter() +type interpreter struct { + common.Interpreter +} + +func NewInterpreter() *interpreter { + return &interpreter{Interpreter: common.NewInterpreter()} +} + +func (i *interpreter) In(field common.FieldName, vals []any) common.Condition { + tuples := make([]common.Tuple, len(vals)) + for i, val := range vals { + tuples[i] = common.Tuple{val} + } + return i.InTuple([]common.FieldName{field}, tuples) +} +func (i *interpreter) InStrings(field common.FieldName, vals []string) common.Condition { + tuples := make([]common.Tuple, len(vals)) + for i, val := range vals { + tuples[i] = common.Tuple{val} + } + return i.InTuple([]common.FieldName{field}, tuples) +} +func (i *interpreter) InInts(field common.FieldName, vals []int) common.Condition { + tuples := make([]common.Tuple, len(vals)) + for i, val := range vals { + tuples[i] = common.Tuple{val} + } + return i.InTuple([]common.FieldName{field}, tuples) +} +func (i *interpreter) InTuple(fields []common.FieldName, vals []common.Tuple) common.Condition { + if len(vals) == 0 || len(fields) == 0 { + return common.EmptyCondition + } + ors := make([]common.Condition, len(vals)) + for j, tuple := range vals { + ands := make([]common.Condition, len(tuple)) + for k, val := range tuple { + ands[k] = i.Cmp(fields[k], "=", val) + } + ors[j] = i.And(ands...) + } + return i.Or(ors...) } diff --git a/platform/view/services/db/driver/sql/sqlite/conditions.go b/platform/view/services/db/driver/sql/sqlite/conditions.go index 4bdd16e19..df3f8e9bb 100644 --- a/platform/view/services/db/driver/sql/sqlite/conditions.go +++ b/platform/view/services/db/driver/sql/sqlite/conditions.go @@ -6,50 +6,8 @@ SPDX-License-Identifier: Apache-2.0 package sqlite -import ( - "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/db/driver/sql/common" -) +import "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/db/driver/sql/common" -type interpreter struct { - common.Interpreter -} - -func NewInterpreter() *interpreter { - return &interpreter{Interpreter: common.NewInterpreter()} -} - -func (i *interpreter) In(field common.FieldName, vals []any) common.Condition { - tuples := make([]common.Tuple, len(vals)) - for i, val := range vals { - tuples[i] = common.Tuple{val} - } - return i.InTuple([]common.FieldName{field}, tuples) -} -func (i *interpreter) InStrings(field common.FieldName, vals []string) common.Condition { - tuples := make([]common.Tuple, len(vals)) - for i, val := range vals { - tuples[i] = common.Tuple{val} - } - return i.InTuple([]common.FieldName{field}, tuples) -} -func (i *interpreter) InInts(field common.FieldName, vals []int) common.Condition { - tuples := make([]common.Tuple, len(vals)) - for i, val := range vals { - tuples[i] = common.Tuple{val} - } - return i.InTuple([]common.FieldName{field}, tuples) -} -func (i *interpreter) InTuple(fields []common.FieldName, vals []common.Tuple) common.Condition { - if len(vals) == 0 || len(fields) == 0 { - return common.EmptyCondition - } - ors := make([]common.Condition, len(vals)) - for j, tuple := range vals { - ands := make([]common.Condition, len(tuple)) - for k, val := range tuple { - ands[k] = i.Cmp(fields[k], "=", val) - } - ors[j] = i.And(ands...) - } - return i.Or(ors...) +func NewInterpreter() common.Interpreter { + return common.NewInterpreter() }