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

Model() ignores primary key in passed argument #6993

Open
zchenyu opened this issue Apr 25, 2024 · 0 comments
Open

Model() ignores primary key in passed argument #6993

zchenyu opened this issue Apr 25, 2024 · 0 comments
Assignees
Labels
type:with reproduction steps with reproduction steps

Comments

@zchenyu
Copy link

zchenyu commented Apr 25, 2024

GORM Playground Link

go-gorm/playground#723

Description

According to https://gorm.io/docs/query.html#Retrieving-objects-with-primary-key

This should work:

var result User
db.Model(User{ID: 10}).First(&result)
// SELECT * FROM users WHERE id = 10;

But instead it ignores the ID in the Model() parameter.

@github-actions github-actions bot added the type:with reproduction steps with reproduction steps label Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:with reproduction steps with reproduction steps
Projects
None yet
Development

No branches or pull requests

2 participants