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

fix: generate sql incorrect when use soft_delete and only one OR #4969

Merged
merged 3 commits into from Dec 30, 2021
Merged

fix: generate sql incorrect when use soft_delete and only one OR #4969

merged 3 commits into from Dec 30, 2021

Conversation

ghost
Copy link

@ghost ghost commented Dec 29, 2021

  • [] Do only one thing
  • [] Non breaking API changes
  • [] Tested

What did this pull request do?

PR for #4914

  • fix generate sql incorrect when use soft_delete and only one or
  • 修复使用 soft_delete 并且仅有一个 or 时生成错误SQL.

User Case Description

Code:

func TestGORMorCondition(t *testing.T) {
	user := User{Name: "jinzhu"}
	DB.Create(&user)

	ret := make([]*User, 0)
	id := []uint32{1}
	db := DB
	for _, id := range id {
		db = db.Or("id = ?", id)
	}
	db.Find(&ret)
}

SQL:

[0.125ms] [rows:1] SELECT * FROM `users` WHERE id = 1 OR `users`.`deleted_at` IS NULL

@ghost ghost linked an issue Dec 29, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

or condition in one condition sql error
2 participants