You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why use difference type receiver?
func (c Carbon) Value() (driver.Value, error)
func (t *DateTime) Value() (driver.Value, error)
one is value receiver, another is pointer receiver
if one struct
type LogData struct {
ID uint32
CreateDay carbon.Carbon
CreateTime carbon.DateTime
}
use gorm to create record, you will see a error
"sql: converting argument $2 type: unsupported type carbon.DateTime, a struct"
if you want to create success, you must define struct like this:
type LogData struct {
ID uint32
CreateDay carbon.Carbon
CreateTime *carbon.DateTime
}
This is really weird.
The text was updated successfully, but these errors were encountered:
Hello,
Why use difference type receiver?
func (c Carbon) Value() (driver.Value, error)
func (t *DateTime) Value() (driver.Value, error)
one is value receiver, another is pointer receiver
if one struct
type LogData struct {
ID uint32
CreateDay carbon.Carbon
CreateTime carbon.DateTime
}
use gorm to create record, you will see a error
"sql: converting argument $2 type: unsupported type carbon.DateTime, a struct"
if you want to create success, you must define struct like this:
type LogData struct {
ID uint32
CreateDay carbon.Carbon
CreateTime *carbon.DateTime
}
This is really weird.
The text was updated successfully, but these errors were encountered: