drizzle-team/drizzle-orm · error · Error

Method not implemented.

Error message

Method not implemented.

What it means

PrismaMySqlPreparedQuery.iterator() throws 'Method not implemented.' because the Prisma bridge routes queries through prisma.$queryRawUnsafe, which returns a fully-materialized result and has no streaming protocol. Streaming cursors are therefore not wired through Prisma's client.

Solutions

  1. Use .all() or .execute() instead of .iterator() and process the returned array.
  2. Paginate with LIMIT/OFFSET or keyset pagination to bound memory.
  3. Switch to a native Drizzle MySQL driver (mysql2) if streaming is a hard requirement.

Example fix

// before (throws)
for await (const row of db.select().from(t).prepare().iterator()) {}

// after
const rows = await db.select().from(t).all();
for (const row of rows) {}
Defensive patterns

Strategy: validation

Validate before calling

import { entityKind } from 'drizzle-orm/entity';

function isPrismaMySqlPrepared(q: any): boolean {
  return q?.[entityKind] === 'PrismaMySqlPreparedQuery';
}

const rows = isPrismaMySqlPrepared(stmt)
  ? await stmt.all()
  : collectAsync(stmt.iterator());

Type guard

function isPrismaMySqlPreparedQuery(q: unknown): boolean {
  return (q as any)?.[Symbol.for('drizzle:entityKind')] === 'PrismaMySqlPreparedQuery';
}

Try / catch

try {
  for await (const row of stmt.iterator()) { /* ... */ }
} catch (e) {
  if (e instanceof Error && e.message === 'Method not implemented.') {
    const rows = await stmt.all();
    for (const row of rows) { /* ... */ }
  } else throw e;
}

Prevention

When it happens

Trigger: Calling .iterator() on any prepared query or select from a PrismaMySQLSession-backed Drizzle db (drizzle(prismaClient, { dialect: 'mysql' })). Using for-await on a Drizzle query object produced via the Prisma adapter.

Common situations: Using Drizzle on top of an existing Prisma datasource to keep Prisma's connection management, then attempting streaming for large exports or ETL. Code migrated from a native MySQL Drizzle driver.

Related errors


AI-assisted analysis of drizzle-team/drizzle-orm@b7862528fd (2026-08-03). Data as JSON: /api/errors/09fabe98d38d2f0a. Report an issue: GitHub.

Appendix: source

Thrown at drizzle-orm/src/prisma/mysql/session.ts:20

import { entityKind } from '~/entity.ts';
import { type Logger, NoopLogger } from '~/logger.ts';
import type {
	MySqlDialect,
	MySqlPreparedQueryConfig,
	MySqlPreparedQueryHKT,
	MySqlQueryResultHKT,
	MySqlTransaction,
	MySqlTransactionConfig,
} from '~/mysql-core/index.ts';
import { MySqlPreparedQuery, MySqlSession } from '~/mysql-core/index.ts';
import { fillPlaceholders } from '~/sql/sql.ts';
import type { Query, SQL } from '~/sql/sql.ts';
import type { Assume } from '~/utils.ts';

export class PrismaMySqlPreparedQuery<T> extends MySqlPreparedQuery<MySqlPreparedQueryConfig & { execute: T }> {
	override iterator(_placeholderValues?: Record<string, unknown> | undefined): AsyncGenerator<unknown, any, unknown> {
		throw new Error('Method not implemented.');
	}
	static override readonly [entityKind]: string = 'PrismaMySqlPreparedQuery';

	constructor(
		private readonly prisma: PrismaClient,
		private readonly query: Query,
		private readonly logger: Logger,
	) {
		super(undefined, undefined, undefined);
	}

	override execute(placeholderValues?: Record<string, unknown>): Promise<T> {
		const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
		this.logger.logQuery(this.query.sql, params);
		return this.prisma.$queryRawUnsafe(this.query.sql, ...params);
	}
}

View on GitHub (pinned to b7862528fd)