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

[support] Is there a way to use not operator in SQL builder #680

Open
ianhe8x opened this issue Jan 27, 2023 · 2 comments
Open

[support] Is there a way to use not operator in SQL builder #680

ianhe8x opened this issue Jan 27, 2023 · 2 comments

Comments

@ianhe8x
Copy link

ianhe8x commented Jan 27, 2023

I'm offering a flexible way for my end user to do query, and therefore seeking a programmatical way to be able to add the NOT operator to all the different db.Cond I've been assembled.

Thanks for any hints.

@Asday
Copy link

Asday commented Jan 27, 2023

https://upper.io/v4/getting-started/sql-builder-api/#where-clause

q = q.Where("id = ? OR id = ?", 5, 4) // Two place holders and two values.

Not that I've tried it, but couldn't you simply do q.Where("NOT id = ?", x)?

@ianhe8x
Copy link
Author

ianhe8x commented Jan 27, 2023

The problem is how to do this programmatically, I can give an example a snippet of code I used,

case "lessThanInsensitive":
			cond = db.Cond{db.Raw(fmt.Sprintf("lower(%s)", field)): db.Lt(db.Raw("lower(?)", input.Field(i).Interface()))}
			break
case "not":
  // if there's something like below?
  // wrappedCond is another db.Cond{}
   cond = db.Not(wrappedCond)

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

2 participants