mirror of
https://gitee.com/johng/gf
synced 2026-06-06 16:21:40 +08:00
enhancement from #1552
This commit is contained in:
@ -17,6 +17,7 @@ import (
|
||||
"github.com/gogf/gf/v2/os/gstructs"
|
||||
"github.com/gogf/gf/v2/text/gregex"
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
"github.com/gogf/gf/v2/util/gutil"
|
||||
)
|
||||
|
||||
// With creates and returns an ORM model based on metadata of given object.
|
||||
@ -248,14 +249,16 @@ func (m *Model) doWithScanStructs(pointer interface{}) error {
|
||||
relatedTargetName, parsedTagOutput.With,
|
||||
)
|
||||
}
|
||||
|
||||
// If related value is empty, it does nothing but just returns.
|
||||
if gutil.IsEmpty(relatedTargetValue) {
|
||||
return nil
|
||||
}
|
||||
// It automatically retrieves struct field names from current attribute struct/slice.
|
||||
if structType, err := gstructs.StructType(field.Value); err != nil {
|
||||
return err
|
||||
} else {
|
||||
fieldKeys = structType.FieldKeys()
|
||||
}
|
||||
|
||||
// Recursively with feature checks.
|
||||
model = m.db.With(field.Value)
|
||||
if m.withAll {
|
||||
|
||||
Reference in New Issue
Block a user