Skip to content

Error: Malformed communication packet. When creating Check Constraint with Between #3725

@qcho

Description

@qcho

Having this error. I've reduced it to the minimal expression.

CREATE TABLE `broken` (
        `confidence` tinyint unsigned NOT NULL,
        CONSTRAINT `confidence_percentage` CHECK(`broken`.`confidence` between ? and ?)
);


Error: Malformed communication packet.
    at PromiseConnection.execute (/Users/qcho/Avature/code/nexus/node_modules/.pnpm/[email protected]/node_modules/mysql2/lib/promise/connection.js:47:22)
    at Object.query (/Users/qcho/Avature/code/nexus/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/bin.cjs:81019:40)
    at mysqlPush (/Users/qcho/Avature/code/nexus/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/bin.cjs:84244:22)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Object.handler (/Users/qcho/Avature/code/nexus/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/bin.cjs:93782:9)
    at async run (/Users/qcho/Avature/code/nexus/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/bin.cjs:93059:7) {
  code: 'ER_MALFORMED_PACKET',
  errno: 1835,
  sql: 'CREATE TABLE `broken` (\n' +
    '\t`confidence` tinyint unsigned NOT NULL,\n' +
    '\tCONSTRAINT `confidence_percentage` CHECK(`broken`.`confidence` between ? and ?)\n' +
    ');\n',
  sqlState: 'HY000',
  sqlMessage: 'Malformed communication packet.'
}

The problem is with the confidence_percentage constraint. If I remove this i works just fine.

  • DrizzleORM source code for the record:
export const brokenTable = mysqlTable(
  "broken",
  {
    confidence: tinyint({ unsigned: true }).notNull()
  },
  (t) => [
    check("confidence_percentage", between(t.confidence, 0, 100)),
  ],
)
  • Mysql query works just fine:
CREATE TABLE `broken` (
        `confidence` tinyint unsigned NOT NULL,
        CONSTRAINT `confidence_percentage` CHECK(`broken`.`confidence` between 0 and 10)
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions