Unable to query records with certain values
See original GitHub issueBug description
Prisma is unable to query database records filtered by values if those values are very specific amounts (e.g., 787.56
and 787.57
).
How to reproduce
Create a database table and insert some values:
CREATE TABLE `demo` (
`id` int NOT NULL AUTO_INCREMENT,
`amount` decimal(11, 2) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
INSERT INTO `demo` SET `amount` = 787.55;
INSERT INTO `demo` SET `amount` = 787.56;
INSERT INTO `demo` SET `amount` = 787.57;
INSERT INTO `demo` SET `amount` = 787.58;
Add the model to the Prisma schema:
model Demo {
id Int @id @default(autoincrement())
amount Float
@@map("demo")
}
Generate the Prisma client, then write some code:
const result55 = await prisma.demo.findMany({
where: {
amount: 787.55,
},
});
console.log(result55);
const result56 = await prisma.demo.findMany({
where: {
amount: 787.56,
},
});
console.log(result56);
const result57 = await prisma.demo.findMany({
where: {
amount: 787.57,
},
});
console.log(result57);
const result58 = await prisma.demo.findMany({
where: {
amount: 787.58,
},
});
console.log(result58);
Run that code, and receive the following output:
[ { id: 1, amount: 787.55 } ]
[]
[]
[ { id: 4, amount: 787.58 } ]
Expected behavior
To receive the following output:
[ { id: 1, amount: 787.55 } ]
[ { id: 2, amount: 787.56 } ]
[ { id: 3, amount: 787.57 } ]
[ { id: 4, amount: 787.58 } ]
Prisma information
generator client {
provider = "prisma-client-js"
output = "../generated-client"
binaryTargets = ["darwin", "darwin-arm64", "debian-openssl-1.1.x", "linux-arm64-openssl-1.1.x"]
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model Demo {
id Int @id @default(autoincrement())
amount Float
@@map("demo")
}
Environment & setup
- OS: Debian Bullseye
- Database: MySQL
- Node.js version: v16.14.0
Prisma Version
prisma : 3.9.2
@prisma/client : 3.9.2
Current platform : darwin-arm64
Query Engine (Node-API) : libquery-engine bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at .yarn/unplugged/@prisma-engines-npm-3.9.0-58.bcc2ff906db47790ee902e7bbc76d7ffb1893009-c1aff4e71f/node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Migration Engine : migration-engine-cli bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at .yarn/unplugged/@prisma-engines-npm-3.9.0-58.bcc2ff906db47790ee902e7bbc76d7ffb1893009-c1aff4e71f/node_modules/@prisma/engines/migration-engine-darwin-arm64)
Introspection Engine : introspection-core bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at .yarn/unplugged/@prisma-engines-npm-3.9.0-58.bcc2ff906db47790ee902e7bbc76d7ffb1893009-c1aff4e71f/node_modules/@prisma/engines/introspection-engine-darwin-arm64)
Format Binary : prisma-fmt bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at .yarn/unplugged/@prisma-engines-npm-3.9.0-58.bcc2ff906db47790ee902e7bbc76d7ffb1893009-c1aff4e71f/node_modules/@prisma/engines/prisma-fmt-darwin-arm64)
Default Engines Hash : bcc2ff906db47790ee902e7bbc76d7ffb1893009
Studio : 0.457.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Unable to run a query with the UniqueValues property - Office
This problem occurs because when you set the UniqueValues query property to Yes, a DISTINCT keyword is added to the resulting SQL statement....
Read more >How to query for rows containing <Unable to read data> in a ...
The SELECT will work fine, but showing the Edit Top 200 Rows in ... Causes DBCC CHECKDB to check the database for column...
Read more >Not able to get field value in SOQL query
In User object Field called ASM__C (Formula Field) and I am retrieving the records based on this field. But I am getting Null...
Read more >Unable to query Account Fields - Salesforce Stack Exchange
This issue is almost certainly caused by Field Level Security . Click into each field and click the Set Field Level Security button....
Read more >unable to query records with data in exponential value
Now the issue is this, In one table I'm able to find/search a particular row by using the exp value within where clause...
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
When using this SQL:
Which is what Migrate generates from the following schema
the queries return the expected results
When using the “decimal(11, 2)” SQL
npx prisma db pull --force
will result in the following schemaAnd then I can reproduce the mentioned unexpected results:
Can reproduce in 3.9.2 and in our internal dev version
4.4.0-dev.30
in
3.9.2
usingPrisma.Decimal()
throwsTypeError: arg2.inputTypes is not iterable
But using new
Prisma.Decimal()
like the following works, in our internal dev version4.4.0-dev.30
!Which means this will be fixed in
4.4.0
Probably related to https://github.com/prisma/prisma/issues/5925