Skip to content

2.8.0 and above: MySQL, 'tinyint unsigned' field considered as 'boolean' #3916

@FredericEspiau

Description

@FredericEspiau

Hello and thanks for the awesome work 🙏

Bug description

A field named dataName in the database is a tinyint unsigned with only values such as 0 and 1

When trying to query this table:

prisma.myTable.findOne({
      where: {
        id: 666,
      },
    });

this error occurs:

 Attempted to serialize scalar 'false' with incompatible type 'Int'

If you don't select the dataName field, there is no error:

prisma.myTable.findOne({
      where: {
        id: 666,
      },
      select: {
        id: true,
        dataName: false,
      }
    });

Introspecting and querying with 2.7.1 works flawlessly

Expected behavior

No bug 😄

Prisma information

Versions

Starting form 2.8.0

Schema

model myTable {
  id                                          Int                   @id @default(autoincrement())
  dataName                               Int                   @default(0)
}

Client debug output

  prisma-client Prisma Client call: +27ms
  prisma-client prisma.myTable.findOne({
  prisma-client   where: {
  prisma-client     id: 666
  prisma-client   }
  prisma-client }) +0ms
  prisma-client Generated request: +0ms
  prisma-client query {
  prisma-client   findOnemyTable(where: {
  prisma-client     id: 666
  prisma-client   }) {
  prisma-client     id
  prisma-client     dataName
  prisma-client   }
  prisma-client }
  prisma-client  +0ms
  engine {
  engine   error: zf [Error]: Attempted to serialize scalar 'false' with incompatible type 'Int'
  engine       at yw.graphQLToJSError (xxx/node_modules/@prisma/client/runtime/index.js:129:4637)
  engine       at xxx/node_modules/@prisma/client/runtime/index.js:129:2977
  engine       at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  engine     clientVersion: '2.9.0'
  engine   }
  engine } +257ms
  prisma-client Error: Attempted to serialize scalar 'false' with incompatible type 'Int'
  prisma-client     at yw.graphQLToJSError (xxx/node_modules/@prisma/client/runtime/index.js:129:4637)
  prisma-client     at xxx/node_modules/@prisma/client/runtime/index.js:129:2977

Environment & setup

  • OS : Mac OS
  • Database: MySQL 8
  • Node.js version: 12.18.3
  • Prisma Version: starting from 2.8.0 to 2.9.0

Here is the output from prisma -v

@prisma/cli          : 2.9.0
@prisma/client       : Not found
Current platform     : darwin
Query Engine         : query-engine 369b3694b7edb869fad14827a33ad3f3f49bbc20 (at ../../.nvm/versions/node/v12.18.3/lib/node_modules/@prisma/cli/query-engine-darwin)
Migration Engine     : migration-engine-cli 369b3694b7edb869fad14827a33ad3f3f49bbc20 (at ../../.nvm/versions/node/v12.18.3/lib/node_modules/@prisma/cli/migration-engine-darwin)
Introspection Engine : introspection-core 369b3694b7edb869fad14827a33ad3f3f49bbc20 (at ../../.nvm/versions/node/v12.18.3/lib/node_modules/@prisma/cli/introspection-engine-darwin)
Format Binary        : prisma-fmt 369b3694b7edb869fad14827a33ad3f3f49bbc20 (at ../../.nvm/versions/node/v12.18.3/lib/node_modules/@prisma/cli/prisma-fmt-darwin)
Studio               : 0.296.0
  • Prisma client version installed in the project: 2.9.0

Summary

Prisma version: 2.9.0
Database type: MySLQ 8
Name of the table: myTable
Name of the field: dataName
Type of the field: tinyint unsigned
All the values in the field are either 0 or 1
Used to work with 2.7.1

Failing query:

prisma.myTable.findOne({
      where: {
        id: 666,
      },
    });

Error:

Attempted to serialize scalar 'false' with incompatible type 'Int'

Succeeding query:

prisma.myTable.findOne({
      where: {
        id: 666,
      },
      select: {
        id: true,
        dataName: false,
      }
    });

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions