mirror of https://github.com/go-gorm/gorm.git
Fix table not supported error when using unexpected table name
This commit is contained in:
parent
0934b10856
commit
f21e35f7c5
|
@ -102,8 +102,8 @@ func (p *processor) Execute(db *DB) *DB {
|
||||||
|
|
||||||
// parse model values
|
// parse model values
|
||||||
if stmt.Model != nil {
|
if stmt.Model != nil {
|
||||||
if err := stmt.Parse(stmt.Model); err != nil && (!errors.Is(err, schema.ErrUnsupportedDataType) || (stmt.Table == "" && stmt.SQL.Len() == 0)) {
|
if err := stmt.Parse(stmt.Model); err != nil && (!errors.Is(err, schema.ErrUnsupportedDataType) || (stmt.Table == "" && stmt.TableExpr == nil && stmt.SQL.Len() == 0)) {
|
||||||
if errors.Is(err, schema.ErrUnsupportedDataType) && stmt.Table == "" {
|
if errors.Is(err, schema.ErrUnsupportedDataType) && stmt.Table == "" && stmt.TableExpr == nil {
|
||||||
db.AddError(fmt.Errorf("%w: Table not set, please set it like: db.Model(&user) or db.Table(\"users\")", err))
|
db.AddError(fmt.Errorf("%w: Table not set, please set it like: db.Model(&user) or db.Table(\"users\")", err))
|
||||||
} else {
|
} else {
|
||||||
db.AddError(err)
|
db.AddError(err)
|
||||||
|
|
Loading…
Reference in New Issue