Skip to content

database/gdb:when inserting an empty struct will cause an error #4351

@llorz-o

Description

@llorz-o

Go version

go version go1.23.7 darwin/arm64

GoFrame version

v2.9.0

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

g.Model(dao.Users.Table()).InsertAndGetId(do.Users{})

What did you see happen?

INSERT INTO users(``) VALUES()

2025-07-30T20:28:14.694+07:00 [ERRO] {e028f0ff780a5718dbb4b163b4d7f441} [ 4 ms] [default] [mim] [rows:0 ] INSERT INTO users(``) VALUES()
Error: Error 1054 (42S22): Unknown column '' in 'field list'
Stack:

  1. mim/internal/logic/auth.(*sLogicAuth).SignUp
    /Users/joe/Dev/GitHub/mim/internal/logic/auth/auth.go:101
  2. mim/internal/controller/api.(*Controller).SignUp
    /Users/joe/Dev/GitHub/mim/internal/controller/api/api.go:36
  3. mim/api/auth._AuthService_SignUp_Handler.func1
    /Users/joe/Dev/GitHub/mim/api/auth/auth_grpc.pb.go:137
  4. google.golang.org/grpc.getChainUnaryHandler.func1
    /Users/joe/go/pkg/mod/google.golang.org/[email protected]/server.go:1217
  5. google.golang.org/grpc.getChainUnaryHandler.func1
    /Users/joe/go/pkg/mod/google.golang.org/[email protected]/server.go:1217
  6. google.golang.org/grpc.getChainUnaryHandler.func1
    /Users/joe/go/pkg/mod/google.golang.org/[email protected]/server.go:1217
  7. google.golang.org/grpc.getChainUnaryHandler.func1
    /Users/joe/go/pkg/mod/google.golang.org/[email protected]/server.go:1217
  8. mim/utils.UnaryMyCtx
    /Users/joe/Dev/GitHub/mim/utils/grpc.go:32
  9. google.golang.org/grpc.getChainUnaryHandler.func1
    /Users/joe/go/pkg/mod/google.golang.org/[email protected]/server.go:1217
  10. google.golang.org/grpc.getChainUnaryHandler.func1
    /Users/joe/go/pkg/mod/google.golang.org/[email protected]/server.go:1217
  11. google.golang.org/grpc.getChainUnaryHandler.func1
    /Users/joe/go/pkg/mod/google.golang.org/[email protected]/server.go:1217
  12. google.golang.org/grpc.getChainUnaryHandler.func1
    /Users/joe/go/pkg/mod/google.golang.org/[email protected]/server.go:1217
  13. google.golang.org/grpc.getChainUnaryHandler.func1
    /Users/joe/go/pkg/mod/google.golang.org/[email protected]/server.go:1217
  14. google.golang.org/grpc.NewServer.chainUnaryServerInterceptors.chainUnaryInterceptors.func1
    /Users/joe/go/pkg/mod/google.golang.org/[email protected]/server.go:1208
  15. mim/api/auth._AuthService_SignUp_Handler
    /Users/joe/Dev/GitHub/mim/api/auth/auth_grpc.pb.go:139
  16. google.golang.org/grpc.(*Server).processUnaryRPC
    /Users/joe/go/pkg/mod/google.golang.org/[email protected]/server.go:1405
  17. google.golang.org/grpc.(*Server).handleStream
    /Users/joe/go/pkg/mod/google.golang.org/[email protected]/server.go:1815
  18. google.golang.org/grpc.(*Server).serveStreams.func2.1
    /Users/joe/go/pkg/mod/google.golang.org/[email protected]/server.go:1035

What did you expect to see?

will not cause an error, cause it's all fields preset default value already.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIt is confirmed a bug, but don't worry, we'll handle it.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions