Skip to content

[BUG] MySQL drizzle client missing 'mode' parameter causes "You need to specify mode" error #727

@oritwoen

Description

@oritwoen

Description

When using NuxtHub Database with MySQL (hub.db: 'mysql'), the generated drizzle client doesn't include the required mode parameter, causing the error:

You need to specify "mode": "planetscale" or "default" when providing a schema. Read more: https://orm.drizzle.team/docs/rqb#modes

Reproduction

  1. Configure NuxtHub with MySQL:
  // nuxt.config.ts
  export default defineNuxtConfig({
    modules: ['@nuxthub/core'],
    hub: {
      db: {
        dialect: 'mysql',
        mode: 'default', // This is ignored
      },
    },
  })
  1. Create a schema in server/db/schema.ts
  2. Try to use import { db } from 'hub:db'
  3. Error appears

Root Cause

In

case 'mysql': {
the mode config option is read but never passed to the drizzle constructor.

The generated code:
const db = drizzle({ connection: {...}, schema })

Should be:
const db = drizzle({ connection: {...}, schema, mode: 'default' })

Expected Behavior

The mode option from hub.db.mode should be passed to the drizzle constructor for MySQL connections.

Environment

  • @nuxthub/core: 0.10.2
  • drizzle-orm: 0.45.1
  • Database: MySQL/MariaDB (non-PlanetScale)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions