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

not: true query with null values does not work #24252

Open
cesarve77 opened this issue May 22, 2024 · 2 comments
Open

not: true query with null values does not work #24252

cesarve77 opened this issue May 22, 2024 · 2 comments
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. domain/client Issue in the "Client" domain: Prisma Client, Prisma Studio etc. kind/bug A reported bug. topic: NOT topic: null topic: where / filter

Comments

@cesarve77
Copy link

Bug description

if a boolean field has true, false and nulls values, the query for not true values does not take in count nulls values.

const countNotTrue = await prisma.test.count({where: {bol: {not: true}}})

How to reproduce

git clone https://github.com/cesarve77/prisma-not-true-query
npm i
npx jest

Expected behavior

a query

{where: {bol: {not: true}}

should return false + null values

Prisma information

in the repo

Environment & setup

  • OS: macOS 14.4.1 (23E224)
  • Database: SQLite
  • Node.js version: v20.13.1

Prisma Version

prisma                  : 5.14.0
@prisma/client          : 5.14.0
Computed binaryTarget   : darwin-arm64
Operating System        : darwin
Architecture            : arm64
Node.js                 : v20.13.1
Query Engine (Node-API) : libquery-engine e9771e62de70f79a5e1c604a2d7c8e2a0a874b48 (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Schema Engine           : schema-engine-cli e9771e62de70f79a5e1c604a2d7c8e2a0a874b48 (at node_modules/@prisma/engines/schema-engine-darwin-arm64)
Schema Wasm             : @prisma/prisma-schema-wasm 5.14.0-25.e9771e62de70f79a5e1c604a2d7c8e2a0a874b48
Default Engines Hash    : e9771e62de70f79a5e1c604a2d7c8e2a0a874b48
Studio                  : 0.500.0
@cesarve77 cesarve77 added the kind/bug A reported bug. label May 22, 2024
@janpio janpio self-assigned this May 22, 2024
@janpio janpio added domain/client Issue in the "Client" domain: Prisma Client, Prisma Studio etc. topic: NOT bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. topic: where / filter topic: null labels May 22, 2024
@janpio janpio changed the title not true query with null values does not work not: true query with null values does not work May 22, 2024
@janpio
Copy link
Contributor

janpio commented May 22, 2024

@cesarve77 The reproduction repository is unfortunately private right now, I can not access it.

Without having looked at the actual code and trying it out, this might very well be expected behavior as Prisma treats nulls the same way as databases (as it just translates the Prisma Client query into SQL, and then the database does its usual thing) and treats them as "not real values" - so not: true does not apply to null and only filters to false values. A solution might be to also filter for null values by using OR. But we'll know more when I can try your code.

@cesarve77
Copy link
Author

The repo now is public.

Maybe what I am looking for is the why to so this:

SELECT count(*) FROM public."Test" Where bol is not true;

Which will return my expected result.

@janpio janpio removed their assignment Jun 5, 2024
@jkomyno jkomyno added bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. domain/client Issue in the "Client" domain: Prisma Client, Prisma Studio etc. kind/bug A reported bug. topic: NOT topic: null topic: where / filter
Projects
None yet
Development

No branches or pull requests

3 participants