question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OR operator behaving like AND

See original GitHub issue

Bug 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:closed
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
timsuchanekcommented, Jan 6, 2021

We need to change this in the DMMF, therefore this is an engines issue.

1reaction
Syttencommented, Jan 1, 2021

@pantharshit00 correction on your comment for clarity, it should only be an array. You wrote the inverse 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found