fix(orm): fix broken Table.Delete method (#11112)
This commit is contained in:
parent
e0543a3be0
commit
888548ab53
|
@ -153,9 +153,9 @@ func (t tableImpl) doSave(writer *batchIndexCommitmentWriter, message proto.Mess
|
||||||
return writer.Write()
|
return writer.Write()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t tableImpl) Delete(context context.Context, message proto.Message) error {
|
func (t tableImpl) Delete(ctx context.Context, message proto.Message) error {
|
||||||
pk := t.PrimaryKeyCodec.GetKeyValues(message.ProtoReflect())
|
pk := t.PrimaryKeyCodec.GetKeyValues(message.ProtoReflect())
|
||||||
return t.DeleteBy(context, pk)
|
return t.doDelete(ctx, pk)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t tableImpl) GetIndex(fields string) Index {
|
func (t tableImpl) GetIndex(fields string) Index {
|
||||||
|
|
|
@ -395,6 +395,13 @@ func runTestScenario(t *testing.T, table ormtable.Table, backend ormtable.Backen
|
||||||
it, err = store.List(ctx, testpb.ExampleTablePrimaryKey{})
|
it, err = store.List(ctx, testpb.ExampleTablePrimaryKey{})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assertIteratorItems(it, 0, 2, 6, 10)
|
assertIteratorItems(it, 0, 2, 6, 10)
|
||||||
|
|
||||||
|
// Let's delete something directly
|
||||||
|
assert.NilError(t, store.Delete(ctx, data[0]))
|
||||||
|
it, err = store.List(ctx, testpb.ExampleTablePrimaryKey{})
|
||||||
|
assert.NilError(t, err)
|
||||||
|
assertIteratorItems(it, 2, 6, 10)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRandomTableData(t *testing.T) {
|
func TestRandomTableData(t *testing.T) {
|
||||||
|
|
|
@ -1098,6 +1098,31 @@ ITERATOR 0100 -> 0101
|
||||||
PK testpb.ExampleTable 9/0/ -> {"u32":9,"b":true}
|
PK testpb.ExampleTable 9/0/ -> {"u32":9,"b":true}
|
||||||
NEXT
|
NEXT
|
||||||
VALID false
|
VALID false
|
||||||
|
GET 0100000000047ffffffffffffffe616263 100e2203616263
|
||||||
|
PK testpb.ExampleTable 4/-2/abc -> {"u32":4,"u64":14,"str":"abc","bz":"abc","i64":-2}
|
||||||
|
ORM DELETE testpb.ExampleTable {"u32":4,"u64":14,"str":"abc","bz":"abc","i64":-2}
|
||||||
|
DEL 0100000000047ffffffffffffffe616263
|
||||||
|
DEL PK testpb.ExampleTable 4/-2/abc -> {"u32":4,"str":"abc","i64":-2}
|
||||||
|
DEL 0101000000000000000e616263
|
||||||
|
DEL ERR:EOF
|
||||||
|
DEL 010261626300000000047ffffffffffffffe
|
||||||
|
DEL IDX testpb.ExampleTable str/u32/i64 : abc/4/-2 -> 4/-2/abc
|
||||||
|
DEL 01030361626361626300000000047ffffffffffffffe
|
||||||
|
DEL IDX testpb.ExampleTable bz/str/u32/i64 : [97 98 99]/abc/4/-2 -> 4/-2/abc
|
||||||
|
ITERATOR 0100 -> 0101
|
||||||
|
VALID true
|
||||||
|
KEY 0100000000047fffffffffffffff616263 10102203616263
|
||||||
|
PK testpb.ExampleTable 4/-1/abc -> {"u32":4,"u64":16,"str":"abc","bz":"abc","i64":-1}
|
||||||
|
NEXT
|
||||||
|
VALID true
|
||||||
|
KEY 0100000000077fffffffffffffff616265 100b
|
||||||
|
PK testpb.ExampleTable 7/-1/abe -> {"u32":7,"u64":11,"str":"abe","i64":-1}
|
||||||
|
NEXT
|
||||||
|
VALID true
|
||||||
|
KEY 0100000000098000000000000000 7801
|
||||||
|
PK testpb.ExampleTable 9/0/ -> {"u32":9,"b":true}
|
||||||
|
NEXT
|
||||||
|
VALID false
|
||||||
CLOSE
|
CLOSE
|
||||||
CLOSE
|
CLOSE
|
||||||
CLOSE
|
CLOSE
|
||||||
|
|
Loading…
Reference in New Issue