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.
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)
Solutions
- Use .all() or .execute() instead of .iterator() and process the returned array.
- Paginate with LIMIT/OFFSET or keyset pagination to bound memory.
- 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
- Do not use .iterator() with the Prisma adapter; document supported methods per adapter.
- Centralize query execution in a data-access layer so the adapter choice only affects one module.
- If streaming is required, switch to a native Drizzle MySQL driver.
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
- Method not implemented.
- Method not implemented.
- Streaming is not supported by the MySql Proxy driver
- You have an empty array for "${name}" enum values
- Your "${f.path.join('->')}" field references a column "${tab
AI-assisted analysis of drizzle-team/drizzle-orm@b7862528fd (2026-08-03).
Data as JSON: /data/errors/09fabe98d38d2f0a.json.
Report an issue: GitHub.