ConversionError when mediumint column is null
See original GitHub issueBug description
Prisma throws a ConversionError
when attempting to retrieve rows from a MySQL database if one of the columns is of type mediumint
and a row contains a NULL
value in that column.
How to reproduce
Create a table that has a column with type mediumint
. Insert at least one row with NULL
in the mediumint
column. Then, use the .findMany()
function to attempt to retrieve data:
CREATE TABLE `items` (
`item_id` int(10) UNSIGNED NOT NULL,
`problematic_column` mediumint(8) UNSIGNED DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
ALTER TABLE `items`
ADD PRIMARY KEY (`item_id`);
INSERT INTO `items` SET `item_id` = 123, `problematic_column` = NULL;
model Item {
@@map("items")
id Int @id @map("item_id")
problematicColumn Int? @map("problematic_column")
}
await prisma.item.findMany();
Expected behavior
No error; NULL
values in the mediumint
column should be retrieved like NULL
values in other column types.
Prisma information
Client Version 2.5.1 Engine Version c88925ce44a9b89b4351aec85ba6a28979d2658e
Environment & setup
- OS: Debian
- Database: MySQL 5.7
- Node.js version: Node.js v12
- Prisma version: see above
Other notes
See https://github.com/prisma/prisma/discussions/3537 for a full discussion of the issue.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Conversion error with NULL column and SELECT INTO
Upon attempting the update statement, I get the error: Conversion failed when converting the varchar value 'Monkey' to data type int. I can ......
Read more >prisma findmany where not null - You.com | The Search Engine You ...
Prisma throws a ConversionError when attempting to retrieve rows from a MySQL database if one of the columns is of type mediumint and...
Read more >YaBB 1 Gold SP1 -> SMF 1.0.6 Conversion Error
Line #1076: Out of range value adjusted for column 'ID_POLL' at row 1. I'm using MySQL 5.0.18 for win32 that is the ......
Read more >Need Help Connect to MySQL using dg4odbc - Page 2 — oracle-tech
CREATE TABLE `bugs` ( `bug_id` mediumint(9) NOT NULL auto_increment, ... Fails with: ORA-28528: Heterogeneous Services datatype conversion error ORA-02063: ...
Read more >conversion.rs - source
... use rusqlite::{ types::{Null, ToSql, ToSqlOutput, ValueRef}, Column, ... let builder = Error::builder(ErrorKind::ConversionError( "Failed to read ...
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
I could reproduce the issue in this PR to our integration tests: https://github.com/prisma/prisma/pull/3583 👍
Okay, so it looks like the problem isn’t if the
mediumint
column has an integer, it’s if the column is set toNULL
. I’ve updated the “how to reproduce” section above accordingly.