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

How to use squirrel.Not to support "Nor", I encountered an unrecognized error here #386

Open
wenbo1989 opened this issue Jan 12, 2025 · 0 comments

Comments

@wenbo1989
Copy link

wenbo1989 commented Jan 12, 2025

I encountered an unrecognized error, my squirrel version is v1.5.4 , seems that there is no "Not" method in "expr.go" file.

I have a Mongo query statement such as below
and I hope to convert it into MySQL.

 {
    "$nor": [
        { "age":20 },
        { "owner1": "a"}
      ]
}

so I write as below

builder := squirrel.Select("*").From("table_name")
ageCondition := squirrel.Eq{"age": 20}
owner1Condition := squirrel.Eq{"owner1": "a"}

andCondition := squirrel.And{
    ageCondition,
    owner1Condition
}
 builder = builder.Where(squirrel.Not(andCondition))  

// I encountered an unrecognized error here,and my squirrel version is v1.5.4 , seems that there is no "Not" method in "expr.go" file.
query, args, err := builder.ToSql()

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

No branches or pull requests

1 participant