mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
improve field filtering for list type parameters of function Data for ForDao models
This commit is contained in:
@ -78,7 +78,7 @@ func (m *Model) Data(data ...interface{}) *Model {
|
||||
// If the `data` parameter is defined like `xxxForDao`,
|
||||
// it then adds `OmitNilData` option for this condition,
|
||||
// which will filter all nil parameters in `data`.
|
||||
if isForDaoModel(reflectInfo.OriginValue.Index(0).Type()) {
|
||||
if isForDaoModel(reflectInfo.OriginValue.Index(0).Elem().Type()) {
|
||||
model = model.OmitNilData()
|
||||
model.option |= optionOmitNilDataInternal
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
package gdb_test
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/test/gtest"
|
||||
"testing"
|
||||
)
|
||||
@ -55,13 +56,13 @@ func Test_Model_Insert_Data_LIst_ForDao(t *testing.T) {
|
||||
Nickname interface{}
|
||||
CreateTime interface{}
|
||||
}
|
||||
data := []UserForDao{
|
||||
{
|
||||
data := g.Slice{
|
||||
UserForDao{
|
||||
Id: 1,
|
||||
Passport: "user_1",
|
||||
Password: "pass_1",
|
||||
},
|
||||
{
|
||||
UserForDao{
|
||||
Id: 2,
|
||||
Passport: "user_2",
|
||||
Password: "pass_2",
|
||||
|
||||
Reference in New Issue
Block a user