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.

ConversionError when mediumint column is null

See original GitHub issue

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

github_iconTop GitHub Comments

1reaction
janpiocommented, Sep 10, 2020

I could reproduce the issue in this PR to our integration tests: https://github.com/prisma/prisma/pull/3583 👍

1reaction
WesCossickcommented, Sep 9, 2020

Okay, so it looks like the problem isn’t if the mediumint column has an integer, it’s if the column is set to NULL. I’ve updated the “how to reproduce” section above accordingly.

Read more comments on GitHub >

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

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