{"id":"09fabe98d38d2f0a","repo":"drizzle-team/drizzle-orm","slug":"method-not-implemented","errorCode":null,"errorMessage":"Method not implemented.","messagePattern":"Method not implemented\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"drizzle-orm/src/prisma/mysql/session.ts","lineNumber":20,"sourceCode":"\nimport { entityKind } from '~/entity.ts';\nimport { type Logger, NoopLogger } from '~/logger.ts';\nimport type {\n\tMySqlDialect,\n\tMySqlPreparedQueryConfig,\n\tMySqlPreparedQueryHKT,\n\tMySqlQueryResultHKT,\n\tMySqlTransaction,\n\tMySqlTransactionConfig,\n} from '~/mysql-core/index.ts';\nimport { MySqlPreparedQuery, MySqlSession } from '~/mysql-core/index.ts';\nimport { fillPlaceholders } from '~/sql/sql.ts';\nimport type { Query, SQL } from '~/sql/sql.ts';\nimport type { Assume } from '~/utils.ts';\n\nexport class PrismaMySqlPreparedQuery<T> extends MySqlPreparedQuery<MySqlPreparedQueryConfig & { execute: T }> {\n\toverride iterator(_placeholderValues?: Record<string, unknown> | undefined): AsyncGenerator<unknown, any, unknown> {\n\t\tthrow new Error('Method not implemented.');\n\t}\n\tstatic override readonly [entityKind]: string = 'PrismaMySqlPreparedQuery';\n\n\tconstructor(\n\t\tprivate readonly prisma: PrismaClient,\n\t\tprivate readonly query: Query,\n\t\tprivate readonly logger: Logger,\n\t) {\n\t\tsuper(undefined, undefined, undefined);\n\t}\n\n\toverride execute(placeholderValues?: Record<string, unknown>): Promise<T> {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues ?? {});\n\t\tthis.logger.logQuery(this.query.sql, params);\n\t\treturn this.prisma.$queryRawUnsafe(this.query.sql, ...params);\n\t}\n}\n","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/drizzle-team/drizzle-orm/blob/b7862528fd8fc39bc2653a6c18dad7c1f4e68d10/drizzle-orm/src/prisma/mysql/session.ts#L2-L38","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (throws)\nfor await (const row of db.select().from(t).prepare().iterator()) {}\n\n// after\nconst rows = await db.select().from(t).all();\nfor (const row of rows) {}","handlingStrategy":"validation","validationCode":"import { entityKind } from 'drizzle-orm/entity';\n\nfunction isPrismaMySqlPrepared(q: any): boolean {\n  return q?.[entityKind] === 'PrismaMySqlPreparedQuery';\n}\n\nconst rows = isPrismaMySqlPrepared(stmt)\n  ? await stmt.all()\n  : collectAsync(stmt.iterator());","typeGuard":"function isPrismaMySqlPreparedQuery(q: unknown): boolean {\n  return (q as any)?.[Symbol.for('drizzle:entityKind')] === 'PrismaMySqlPreparedQuery';\n}","tryCatchPattern":"try {\n  for await (const row of stmt.iterator()) { /* ... */ }\n} catch (e) {\n  if (e instanceof Error && e.message === 'Method not implemented.') {\n    const rows = await stmt.all();\n    for (const row of rows) { /* ... */ }\n  } else throw e;\n}","preventionTips":["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."],"tags":["prisma","mysql","streaming","not-implemented","adapter"],"analyzedSha":"b7862528fd8fc39bc2653a6c18dad7c1f4e68d10","analyzedAt":"2026-08-03T18:11:14.318Z","schemaVersion":2}