Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why use difference type receiver? #262

Open
luzj opened this issue Dec 6, 2024 · 1 comment
Open

Why use difference type receiver? #262

luzj opened this issue Dec 6, 2024 · 1 comment
Labels
Bug Report a reproducible bug or regression

Comments

@luzj
Copy link

luzj commented Dec 6, 2024

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.

@luzj luzj added the Bug Report a reproducible bug or regression label Dec 6, 2024
@gouguoyin
Copy link
Collaborator

I will test and verify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Report a reproducible bug or regression
Projects
None yet
Development

No branches or pull requests

2 participants