From 01a80f0b3f6de4b75bbc6f59963128b9197dce5d Mon Sep 17 00:00:00 2001 From: congqixia Date: Wed, 17 Jan 2024 16:24:46 +0800 Subject: [PATCH] fix: [Cherry-pick] deduce AutoID from field info (#656) cherry pick from master pr: #655 Resolves: #654 --------- Signed-off-by: Congqi Xia --- entity/schema.go | 4 +++- entity/schema_test.go | 1 - test/testcases/collection_test.go | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/entity/schema.go b/entity/schema.go index ee7179ab..08e6a6c5 100644 --- a/entity/schema.go +++ b/entity/schema.go @@ -107,11 +107,13 @@ func (s *Schema) ProtoMessage() *schema.CollectionSchema { // ReadProto parses proto Collection Schema func (s *Schema) ReadProto(p *schema.CollectionSchema) *Schema { - s.AutoID = p.GetAutoID() s.Description = p.GetDescription() s.CollectionName = p.GetName() s.Fields = make([]*Field, 0, len(p.GetFields())) for _, fp := range p.GetFields() { + if fp.GetAutoID() { + s.AutoID = true + } s.Fields = append(s.Fields, NewField().ReadProto(fp)) } s.EnableDynamicField = p.GetEnableDynamicField() diff --git a/entity/schema_test.go b/entity/schema_test.go index 07d07de6..47117527 100644 --- a/entity/schema_test.go +++ b/entity/schema_test.go @@ -107,7 +107,6 @@ func (s *SchemaSuite) TestBasic() { nsch = nsch.ReadProto(p) s.Equal(sch.CollectionName, nsch.CollectionName) - s.Equal(sch.AutoID, nsch.AutoID) s.Equal(sch.Description, nsch.Description) s.Equal(sch.EnableDynamicField, nsch.EnableDynamicField) s.Equal(len(sch.Fields), len(nsch.Fields)) diff --git a/test/testcases/collection_test.go b/test/testcases/collection_test.go index 4c32d146..2cd6cb48 100644 --- a/test/testcases/collection_test.go +++ b/test/testcases/collection_test.go @@ -419,7 +419,7 @@ func TestCreateJsonCollection(t *testing.T) { // schema collName := common.GenRandomString(6) - schema := common.GenSchema(collName, false, fields) + schema := common.GenSchema(collName, true, fields) // create collection err := mc.CreateCollection(ctx, schema, common.DefaultShards)