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.

Unable to read <null> decimal with SQLite

See original GitHub issue

Bug description

Having the following field in a SQLite database:

scheduled_distance NUMERIC (6, 3)

and in schema.prisma:

scheduledDistance Decimal?   @map("scheduled_distance")

will give:

Invalid `prisma.race.findMany()` invocation:\n\n\n  
Inconsistent column data: Conversion failed: Value NUMERIC(6,3) not supported

in case a record contains a null value for this column.

So e.g. value 806.982, 806 works, but null gives the above error. Note I mean actual null not a "null" string.

As it is an optional column null should be possible.

How to reproduce

See bug description.

Expected behavior

Rows with e.g. null to be read successfully.

Prisma information

See bug description.

Environment & setup

  • OS: Mac OS
  • Database: SQLite
  • Node.js version: v17.6.0

Prisma Version

3.11.0

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
marceloverdijkcommented, Mar 25, 2022

@janpio good point indeed… I introspected with older version some time ago. So probably good to see if latest version is doing that as well.

0reactions
janpiocommented, Mar 25, 2022

But if the database is scheduled_distance NUMERIC (6, 3), which is not actually valid for SQL from what you wrote, why should it introspect this as Decimal?? Wouldn’t it be better to not introspect that field then?

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQLite not storing decimals correctly - Stack Overflow
there is no other type in SQLite. there is only "Text", "Integer", "Real" and "Blob" also in SQLite it says integer can have...
Read more >
Division by decimals wrongly returning a rounded int ... - SQLite
I just had this issue where a division by 2 decimals is rounding some numbers if they don't have a floating point in...
Read more >
SQLite Transaction Explained By Practical Examples
Learn how to deal with SQLite transactions by using the BEGIN TRANSACTION, ... CREATE TABLE accounts ( account_no INTEGER NOT NULL, balance DECIMAL...
Read more >
Part 4, add a model to an ASP.NET Core MVC app
Use the scaffolding tool to produce Create , Read , Update , and Delete ... You may not be able to enter decimal...
Read more >
How to Import a Tab Delimited File with SQLite - Medium
INSERT failed: NOT NULL constraint failed: sales.listid (*columns' names*) ... smallint not null,qtysold smallint not null,pricepaid decimal(8,2),commission ...
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