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

Query.Not() doesn't apply to WhereRaw #598

Closed
SunnyC17 opened this issue Aug 26, 2022 · 2 comments
Closed

Query.Not() doesn't apply to WhereRaw #598

SunnyC17 opened this issue Aug 26, 2022 · 2 comments

Comments

@SunnyC17
Copy link

SunnyC17 commented Aug 26, 2022

When I am using Not(), the WhereRaw clause is not negated. I have to use WhereRaw instead of Where in my use case so would there be a fix to this issue? Suggestions for work-around will also be appreciated.

var query = new Query("Posts").Not();
query = query.WhereRaw("lower(Title) = ?", "sql");

returns

SELECT
  *
FROM
  [Posts]
WHERE
  lower(Title) = 'sql'
@ahmad-moussawi
Copy link
Contributor

ahmad-moussawi commented Aug 29, 2022

Yes this intended, and should be mentioned in the doc, why not negating directly your expression?
as a workaround you can nest your condition with

`WhereNot(q => q.WhereRaw("A = B"))

check
https://sqlkata.com/playground?code=var%20query%20%3D%20new%20Query(%22A%22).WhereNot(q%20%3D%3E%20q.WhereRaw(%22A%20%3D%20B%22

@SunnyC17
Copy link
Author

SunnyC17 commented Sep 8, 2022

Thanks for the workaround, the issue at my end has been resolved.

@SunnyC17 SunnyC17 closed this as completed Sep 8, 2022
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