Skip to content
This repository has been archived by the owner on Jun 14, 2019. It is now read-only.

Fix empty IN/NOT IN conditions #4

Merged
merged 1 commit into from
May 19, 2017
Merged

Conversation

ethantkoenig
Copy link
Contributor

For empty IN clauses, xorm generates SQL of the form <col> IN () (similarly for NOT IN). This is not accepted by either MySQL or PostgreSQL, and might as well be replaced with false (0=1) and true (0=0) conditions, respectively

return err
}
return nil
_, err := fmt.Fprint(w, "0=0")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not "1=0"? consider x.NotIn("id", []int64{}).Delete(new(User))

Copy link
Contributor Author

@ethantkoenig ethantkoenig May 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't your example delete all users (i.e. every user whose id is not in the empty list)? So we would want "0=0", not "1=0".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@lunny lunny merged commit 31ad0dd into go-xorm:master May 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants