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 specify length of TinyInt in MySQL engine

See original GitHub issue

Hi,

We are attempting to port over our code from Sequelize to Prisma. However we have an issue where some of our database fields are TinyInt(1), but also actually represent Integers.

Introspect defaults to mapping them to boolean, which is understandable. We can correct the mapping to Integer @db.TinyInt, however this wants to map to TinyInt(3), altering the database schema and attempting to wipe the dev database.

According to https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#mysql-1 it is possible to specify @db.TinyInt(1) as a type, however in practice prisma complains that TinyInt doesn’t take any arguments.

I found this Issue - https://github.com/prisma/prisma-engines/issues/1182 which appears to implement this, however the associated PR was closed without ever being merged.

Can I ask why this support was abandoned, if it is still being considered, and if there is any way around it for our problem?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
cfraz89commented, Nov 15, 2021

Hey @janpio it is documented that way, but in practice it’s an invalid schema, as TinyInt doesnt have arguments… Prisma will complain that you have provided an argument to TinyInt when it takes 0. It appears that the PR to add support for this https://github.com/prisma/prisma-engines/pull/1191 was never merged.

0reactions
janpiocommented, Jul 29, 2022

Note that there is a closed PR that could be part of changing this: https://github.com/prisma/prisma-engines/pull/1191

Read more comments on GitHub >

github_iconTop Results From Across the Web

MySQL 8 ignoring integer lengths - Stack Overflow
The type is TINYINT(1). MySQL Connectors make the assumption that TINYINT(1) columns originated as BOOLEAN columns; this exception enables them ...
Read more >
mysql - Why the length of tinyint seems to make no difference?
In SQL, INTEGER types are not defined by the number of digits. Instead the number of bytes available to represent the value are...
Read more >
13.1.7.2 ALTER TABLE Examples - MySQL :: Developer Zone
To change column a from INTEGER to TINYINT NOT NULL (leaving the name the same) ... DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 1 row...
Read more >
11.1.7 Out-of-Range and Overflow Handling
When MySQL stores a value in a numeric column that is outside the permissible range of the column data type, the result depends...
Read more >
MySQL 8.0 Reference Manual :: 11.6 Data Type Default Values
The default value specified in a DEFAULT clause can be a literal constant or an ... column or column with an expression default...
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