MCPcopy Create free account
hub / github.com/Effect-TS/effect / encodeBatch

Function encodeBatch

packages/sql/pg/src/PgConnection.ts:1377–1399  ·  view source on GitHub ↗
(
  statements: ReadonlyArray<BatchStatement>,
  registry: PgTypes.Registry | undefined,
  encodeBind: BindEncoder
)

Source from the content-addressed store, hash-verified

1375 * and is never retried.
1376 */
1377const encodeBatch = (
1378 statements: ReadonlyArray<BatchStatement>,
1379 registry: PgTypes.Registry | undefined,
1380 encodeBind: BindEncoder
1381): Plan => {
1382 const chunks: Array<Uint8Array> = []
1383 for (const statement of statements) {
1384 const { parameterTypes, parameters } = inferParameters(statement.params ?? emptyParams, registry)
1385 const [parse, bind] = encodeUnnamedParseBind(statement.sql, parameters, parameterTypes, encodeBind)
1386 chunks.push(parse, bind, describeExecute)
1387 }
1388 chunks.push(sync)
1389 return {
1390 frame: concat(chunks),
1391 closes: 0,
1392 parses: true,
1393 describes: true,
1394 prepared: undefined,
1395 description: undefined,
1396 stale: false,
1397 statements: statements.length
1398 }
1399}
1400
1401/**
1402 * Builds one extended-query cycle as a single buffer, so a statement costs one

Callers 2

PgConnectionImplClass · 0.85

Calls 4

inferParametersFunction · 0.85
encodeUnnamedParseBindFunction · 0.85
concatFunction · 0.70
pushMethod · 0.65

Tested by

no test coverage detected