OR operator behaving like AND
See original GitHub issueBug description
Generated query with OR
uses AND
instead.
How to reproduce
With any schema, use query with OR
in ˙where˙.
const carriersToProcess = await prisma.carrier.findMany({
select: {
carrierID: true,
lat: true,
lng: true,
},
where: {
lat: { gt: 0 },
lng: { gt: 0 },
origin: { not: { equals: 'S' } },
OR: {
regionID: { equals: null },
districtID: { equals: null },
},
},
})
Actual behavior
SELECT `db`.`carrier`.`carrierID`, `db`.`carrier`.`lat`, `db`.`carrier`.`lng` FROM `db`.`carrier`
WHERE (
`db`.`carrier`.`lat` > ? AND
`db`.`carrier`.`lng` > ? AND
`db`.`carrier`.`Zdroj` <> ? AND (
`db`.`carrier`.`regionID` IS NULL AND
`db`.`carrier`.`districtID` IS NULL )
)
ORDER BY `db`.`carrier`.`carrierID` ASC LIMIT ? OFFSET ?
Expected behavior
SELECT `db`.`carrier`.`carrierID`, `db`.`carrier`.`lat`, `db`.`carrier`.`lng` FROM `db`.`carrier`
WHERE (
`db`.`carrier`.`lat` > ? AND
`db`.`carrier`.`lng` > ? AND
`db`.`carrier`.`Zdroj` <> ? AND (
`db`.`carrier`.`regionID` IS NULL OR
`db`.`carrier`.`districtID` IS NULL )
)
ORDER BY `db`.`carrier`.`carrierID` ASC LIMIT ? OFFSET ?
Environment & setup
- OS: Windows
- Database: MySQL
- Node.js version: v12.16.1
- Prisma version:
@prisma/cli : 2.12.1
@prisma/client : 2.12.1
Current platform : windows
Query Engine : query-engine cf0680a1bfe8d5e743dc659cc7f08009f9587d58 (at node_modules\@prisma\engines\query-engine-windows.exe)
Migration Engine : migration-engine-cli cf0680a1bfe8d5e743dc659cc7f08009f9587d58 (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine : introspection-core cf0680a1bfe8d5e743dc659cc7f08009f9587d58 (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary : prisma-fmt cf0680a1bfe8d5e743dc659cc7f08009f9587d58 (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Studio : 0.322.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
c# - && operator behaves like || operator - Stack Overflow
I am a beginner and I've been trying to run a program that prints all the numbers from 1 to N (user input)...
Read more >Logical OR (||) - JavaScript - MDN Web Docs - Mozilla
The logical OR (||) (logical disjunction) operator for a set of operands is true if and only if one or more of its...
Read more >Exploring JavaScript's Logical OR Operator - Addy Osmani
In JavaScript, logical operators are used for boolean logic where a boolean value may be returned depending on the outcome of an expression....
Read more >Comparison and Logical Operators - Codecademy
(or) — This operator will be truthy if the expression on either side of it is true. Otherwise, it will be falsy (act...
Read more >Mastering JavaScript's && and || logical operators - Medium
The || operator behaves exactly like the && does, only in reverse! While a chain of && s will break if a falsy...
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 FreeTop 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
Top GitHub Comments
We need to change this in the DMMF, therefore this is an engines issue.
@pantharshit00 correction on your comment for clarity, it should only be an array. You wrote the inverse 😃