这是我的 model type TenantDataSource struct { Db *gorm.DB json:"-" AutoID int gorm:"primary_key" json:"autoId" TenantID int json:"tenantId" TenantCode string json:"tenantCode" Version int json:"version" Name string json:"name" URL string json:"url" UserName string json:"-" //敏感数据,不传到前端 Password string json:"-" //敏感数据,不传到前端 DriverClassname string json:"driverClassname" PoolSize string json:"poolSize" ExpMinute string json:"expMinute" }

//TableName 设置表名 func (TenantDataSource) TableName() string { return "crm.tenant_datasource" }

//GetByTenantID 根据租户号取得第一条数据源 func (t TenantDataSource) GetByTenantID(tenantID string) (TenantDataSource, error) { var tds []TenantDataSource t.Db.Where("tenant_id = ?", tenantID).Find(&tds) if len(tds) == 0 { return nil, errors.New("数据源未配置!") } if len(tds) > 1 { return nil, errors.New("数据源中找到多个配置,请检查!") } return &tds[0], nil } 出现一下错误

invalid embedded struct for Config's field Dialector, should be struct, but got gorm.Dialector unsupported data type: gorm.io/gorm/schema.Namer

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 2 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: asura-10

Db *gorm.DB json:"-"

第二行这里应该是:Db *gorm.DB gorm:"-"