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

Using clause.Not and clause.And result in erroneous simplification #767

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ezk84
Copy link

@ezk84 ezk84 commented Oct 22, 2024

When using clause.Not and clause.And to create query Where conditions and faulty simplification is applied:

NOT(col1 = val1 AND col2 = val2) gets turned into (col1 <> val1 AND col2 <> val2), which is wrong.

The right simplification is to turn the AND into an OR, by De Morgan's Laws, so (col1 <> OR val1 AND col2 <> val2)

This is a regression that was introduced into gorm in 1.25.6. Testing against 1.25.5 returns the correct condition and expected rows in the included tests.

(This PR includes changes to the go.mod file to be able to compile as per #751, so it assumes the gorm.io/gen repo has been cloned into the ./gen folder. Additionally, there are some replaces to make sure testing against 1.25.5 can compile, tests still fail against gorm master with and without these replaces).

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.

1 participant