refactor: Resolve implicit memory aliasing in for loop (#6730)

This commit is contained in:
BugKillerPro 2023-12-15 16:31:23 +08:00 committed by GitHub
parent f0af94cd16
commit 2fb4928aa8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -163,8 +163,8 @@ func checkSchemaRelation(t *testing.T, s *schema.Schema, relation Relation) {
t.Errorf("schema %v relation's join table tablename expects %v, but got %v", s, relation.JoinTable.Table, r.JoinTable.Table) t.Errorf("schema %v relation's join table tablename expects %v, but got %v", s, relation.JoinTable.Table, r.JoinTable.Table)
} }
for _, f := range relation.JoinTable.Fields { for i := range relation.JoinTable.Fields {
checkSchemaField(t, r.JoinTable, &f, nil) checkSchemaField(t, r.JoinTable, &relation.JoinTable.Fields[i], nil)
} }
} }

View File

@ -46,8 +46,8 @@ func checkUserSchema(t *testing.T, user *schema.Schema) {
{Name: "Active", DBName: "active", BindNames: []string{"Active"}, DataType: schema.Bool}, {Name: "Active", DBName: "active", BindNames: []string{"Active"}, DataType: schema.Bool},
} }
for _, f := range fields { for i := range fields {
checkSchemaField(t, user, &f, func(f *schema.Field) { checkSchemaField(t, user, &fields[i], func(f *schema.Field) {
f.Creatable = true f.Creatable = true
f.Updatable = true f.Updatable = true
f.Readable = true f.Readable = true
@ -136,8 +136,8 @@ func TestParseSchemaWithAdvancedDataType(t *testing.T) {
{Name: "Admin", DBName: "admin", BindNames: []string{"Admin"}, DataType: schema.Bool}, {Name: "Admin", DBName: "admin", BindNames: []string{"Admin"}, DataType: schema.Bool},
} }
for _, f := range fields { for i := range fields {
checkSchemaField(t, user, &f, func(f *schema.Field) { checkSchemaField(t, user, &fields[i], func(f *schema.Field) {
f.Creatable = true f.Creatable = true
f.Updatable = true f.Updatable = true
f.Readable = true f.Readable = true