Open geovanisouza92 opened 6 months ago
drizzle-orm
0.30.10
drizzle-kit
0.21.4
When I'm using an .iterator(params) on a prepared statement (cloneClients), I don't see any Query: select ... logs, but I noticed that .execute(params) (cloneEdgesServices) works fine.
.iterator(params)
cloneClients
Query: select ...
.execute(params)
cloneEdgesServices
See Query: select... logs from .iterator(params) just like .execute(params) calls.
Query: select...
same problem here ps: using mysql 8.0 and drizzle-orm 0.36.2
What version of
drizzle-orm
are you using?0.30.10
What version of
drizzle-kit
are you using?0.21.4
Describe the Bug
When I'm using an
.iterator(params)
on a prepared statement (cloneClients
), I don't see anyQuery: select ...
logs, but I noticed that.execute(params)
(cloneEdgesServices
) works fine.Code samples
```ts // connection.ts import { drizzle } from "drizzle-orm/mysql2"; import { createConnection } from "mysql2"; import { config } from "../config"; export const connection = createConnection(config.DATABASE_URL); export const db = drizzle(connection, { logger: true, }); export type DB = typeof db; ``` ```ts // queries.ts const selectClients = db .select() .from(clients) .where(inArray(clients.serviceId, sql`(${sql.placeholder('sourceServiceIds')})`)) .prepare(); export async function cloneClients(sourceServiceIds: number[], targetServiceId: number) { const inserts = []; for await (const client of selectClients.iterator({ sourceServiceIds })) { const newClient: typeof clients.$inferInsert = { ...client, // omitted }; inserts.push(db.insert(clients).values(newClient)); } await Promise.all(inserts); } const selectEdgesServices = db .select({ edgeId: edgesServices.edgeId, active: edgesServices.active, }) .from(edgesServices) .where(inArray(edgesServices.serviceId, sql`(${sql.placeholder('sourceServiceIds')})`)) .prepare(); export async function cloneEdgesServices(sourceServiceIds: number[], targetServiceId: number) { const rows = await selectEdgesServices.execute({ sourceServiceIds }); const values = rows.map((edgeService): typeof edgesServices.$inferInsert => ({ ...edgeService, // omitted })); await db.insert(edgesServices).values(values); } ```Expected behavior
See
Query: select...
logs from.iterator(params)
just like.execute(params)
calls.Environment & setup