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

单独where引起的查询bug #7306

Closed
nzlov opened this issue Dec 6, 2024 · 1 comment
Closed

单独where引起的查询bug #7306

nzlov opened this issue Dec 6, 2024 · 1 comment
Assignees
Labels
type:with reproduction steps with reproduction steps

Comments

@nzlov
Copy link

nzlov commented Dec 6, 2024

GORM Playground Link

go-gorm/playground#777

Description

第二个First没有查询toys

func TestGORM(t *testing.T) {
	user := User{Name: "jinzhu", Age: 5}
	toy := Toy{Name: "jinzhu", OwnerID: "test"}

	DB.Create(&user)
	DB.Create(&toy)

	var result User

	DB = DB.Where("name = ?", "jinzhu")

	if err := DB.First(&result, "age = ?", 5).Error; err != nil {
		t.Errorf("Failed, got error: %v", err)
	}

	var ttoy Toy
	if err := DB.First(&ttoy, "owner_id = ?", "test").Error; err != nil {
		t.Errorf("Failed, got error: %v", err)
	}
}
@github-actions github-actions bot added the type:with reproduction steps with reproduction steps label Dec 6, 2024
@nzlov
Copy link
Author

nzlov commented Dec 9, 2024

@nzlov nzlov closed this as completed Dec 9, 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