diff --git a/internal/dbtest/orm_test.go b/internal/dbtest/orm_test.go index 891345037..a5e46006e 100644 --- a/internal/dbtest/orm_test.go +++ b/internal/dbtest/orm_test.go @@ -504,10 +504,10 @@ func (*Book) BeforeAppendModel(ctx context.Context, query bun.Query) error { } // BookWithCommentCount is like Book model, but has additional CommentCount -// field that is used to select data into it. The use of `bun:",inherit"` tag -// is essential here so it inherits internal model properties such as table name. +// field that is used to select data into it. The use of `bun:",extend"` tag +// is essential here. type BookWithCommentCount struct { - Book `bun:",inherit"` + Book `bun:",extend"` CommentCount int } diff --git a/schema/table.go b/schema/table.go index ef5f89c61..927f4aa01 100644 --- a/schema/table.go +++ b/schema/table.go @@ -232,7 +232,7 @@ func (t *Table) addFields(typ reflect.Type, prefix string, index []int) { t.addFields(fieldType, "", withIndex(index, f.Index)) tag := tagparser.Parse(f.Tag.Get("bun")) - if _, inherit := tag.Options["inherit"]; inherit { + if tag.HasOption("inherit") || tag.HasOption("extend") { embeddedTable := t.dialect.Tables().Ref(fieldType) t.TypeName = embeddedTable.TypeName t.SQLName = embeddedTable.SQLName