Combined $and and $or in search request generates only AND operators
See original GitHub issueHi,
When I query this :
{
"$and": [
{
"createdAt": {
"$lte": "2020-03-13T15:49:37.289Z"
}
},
{
"$or": [
{
"name": {
"$contL": "a"
},
"email": {
"$contL": "a"
}
}
]
}
]
}
I get this generated query :
SELECT * FROM "users" "User" WHERE "User"."createdAt" <= $1 AND ("User"."name" ILIKE $2 AND "User"."email" ILIKE $3) -- PARAMETERS: ["2020-03-13T15:50:59.592Z","%a%","%a%"]
I was expecting this :
SELECT * FROM "users" "User" WHERE "User"."createdAt" <= $1 AND ("User"."name" ILIKE $2 OR "User"."email" ILIKE $3) -- PARAMETERS: ["2020-03-13T15:50:59.592Z","%a%","%a%"]
am I doing something wrong in the search params ?
Thanks !
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
Search Techniques: Combining search terms
How to combine search terms: Using AND, OR and NOT. The three most commonly used operators are AND, OR, NOT. These are known...
Read more >Google Search Operators: The Complete List (42 Advanced ...
My aim here is to show that you can achieve almost anything with Google advanced operators if you know how to use and...
Read more >Search Operators | GovInfo
A space is used to separate words or operators in a search query. In a simple query where operators are not used, spaces...
Read more >Refine web searches - Google Search Help
Combine searches. Put " OR " between each search query. For example, marathon OR race . Search for a specific site.
Read more >Advanced search options - Microsoft Support
Because OR is the operator with lowest precedence, enclose OR terms in parentheses when combined with other operators in a search.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The issue is that nesting in the first post is not correct (
or
part is nested incorrectly). It should be:I’ve tested this type of nested conditions with the latest version of CRUD library and it works as expected for me.
To avoid this kind of issues in the future I suggest writing search conditions the following way:
Of course, my bad!
Thanks a lot