remix-run/remix · error · DataTableQueryError

createMany({ returnRows: true }) is not supported by this da

Error message

createMany({ returnRows: true }) is not supported by this database

What it means

createMany with returnRows: true needs the database to return all inserted rows in one statement (RETURNING). The method checks this.capabilities.returning first and throws immediately on drivers that don't advertise it, rather than silently returning fewer rows than were inserted.

Source

Thrown at packages/data-table/src/lib/database.ts:635

    table: table,
    values: Array<Partial<TableRow<table>>>,
    options?: CreateManyResultOptions,
  ): Promise<WriteResult>
  createMany<table extends AnyTable>(
    table: table,
    values: Array<Partial<TableRow<table>>>,
    options: CreateManyRowsOptions,
  ): Promise<TableRow<table>[]>
  async createMany<table extends AnyTable>(
    table: table,
    values: Array<Partial<TableRow<table>>>,
    options?: CreateManyResultOptions | CreateManyRowsOptions,
  ): Promise<WriteResult | TableRow<table>[]> {
    let query: QueryForTable<table> = this.query(asQueryTableInput(table))

    if (options?.returnRows === true) {
      if (!this.capabilities.returning) {
        throw new DataTableQueryError(
          'createMany({ returnRows: true }) is not supported by this database',
        )
      }

      let result = (await query.insertMany(values, {
        returning: '*',
        touch: options.touch,
      })) as { rows: TableRow<table>[] }

      return result.rows
    }

    let result = await query.insertMany(values, {
      touch: options?.touch,
    })

    return toWriteResult(result)
  }

View on GitHub (pinned to 9696913134)

Solutions

  1. Drop returnRows: true and re-fetch the inserted rows with a find if you need them, or use create() per row with returnRow on capable drivers.
  2. Branch on db.capabilities.returning before choosing the options.
  3. Custom driver authors: implement and advertise returning, or keep the capability flag false and handle the fallback.

Example fix

// before
let rows = await db.createMany(users, values, { returnRows: true })

// after
await db.createMany(users, values)
let rows = await db.find(users, inArray(users.email, emails))
Defensive patterns

Strategy: validation

Validate before calling

if (options.returnRows && !db.capabilities.returning) {
  await db.createMany(table, rows)
  return db.find(table, inArray(table.email, rows.map((r) => r.email)))
}
return db.createMany(table, rows, options)

Prevention

When it happens

Trigger: Calling db.createMany(table, rows, { returnRows: true }) on a driver whose capabilities.returning is false (e.g. MySQL-style drivers without multi-row RETURNING).

Common situations: Porting code from SQLite/Postgres to MySQL; reusing a helper that always requests returnRows across multiple databases; custom drivers that forgot to declare returning capability.

Related errors


AI-assisted analysis of remix-run/remix@9696913134 (2026-08-27). Data as JSON: /api/errors/e06d5e5895a83db3. Report an issue: GitHub.