Rolled back the behaviour of tag "embedded"

It's now required to use "embedded:fixed"
This commit is contained in:
Dmitry Yu Okunev 2015-05-21 12:30:16 +03:00
parent 18616d53c4
commit 81ceeb3e9f
No known key found for this signature in database
GPG Key ID: AD8AE40C8E30679C
2 changed files with 6 additions and 4 deletions

View File

@ -1177,8 +1177,8 @@ db.Where("email = ?", "x@example.org").Attrs(User{RegisteredIp: "111.111.111.111
```go ```go
type Delta struct { type Delta struct {
Id int; Id int;
Was interface{} `gorm:"embedded"`; Was interface{} `gorm:"embedded:prefixed"`;
Became interface{} `gorm:"embedded"`; Became interface{} `gorm:"embedded:prefixed"`;
} }
type Login struct { type Login struct {

View File

@ -299,10 +299,12 @@ func (scope *Scope) GetModelStruct() *ModelStruct {
field.IsNormal = true field.IsNormal = true
} }
case reflect.Struct: case reflect.Struct:
if _, ok := gormSettings["EMBEDDED"]; ok || fieldStruct.Anonymous { if embType, ok := gormSettings["EMBEDDED"]; ok || fieldStruct.Anonymous {
for _, toField := range toScope.GetStructFields() { for _, toField := range toScope.GetStructFields() {
toField = toField.clone() toField = toField.clone()
if (embType == "prefixed") {
toField.DBName = field.DBName+"__"+toField.DBName toField.DBName = field.DBName+"__"+toField.DBName
}
toField.Names = append([]string{fieldStruct.Name}, toField.Names...) toField.Names = append([]string{fieldStruct.Name}, toField.Names...)
modelStruct.StructFields = append(modelStruct.StructFields, toField) modelStruct.StructFields = append(modelStruct.StructFields, toField)
if toField.IsPrimaryKey { if toField.IsPrimaryKey {