Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [Cherry-pick] deduce AutoID from field info #656

Merged
merged 2 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion entity/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion entity/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion test/testcases/collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading