MCPcopy Index your code
hub / github.com/electric-sql/pglite / describeQuery

Function describeQuery

packages/pglite/src/base.ts:331–370  ·  view source on GitHub ↗

* Describe a query * @param query The query to describe * @returns A description of the result types for the query

(
    query: string,
    options?: QueryOptions,
  )

Source from the content-addressed store, hash-verified

329 * @returns A description of the result types for the query
330 */
331 async describeQuery(
332 query: string,
333 options?: QueryOptions,
334 ): Promise<DescribeQueryResult> {
335 try {
336 await this.#execProtocolNoSync(
337 serializeProtocol.parse({ text: query, types: options?.paramTypes }),
338 options,
339 )
340
341 const describeResults = await this.#execProtocolNoSync(
342 serializeProtocol.describe({ type: 'S' }),
343 options,
344 )
345 const paramDescription = describeResults.messages.find(
346 (msg): msg is ParameterDescriptionMessage =>
347 msg.name === 'parameterDescription',
348 )
349 const resultDescription = describeResults.messages.find(
350 (msg): msg is RowDescriptionMessage => msg.name === 'rowDescription',
351 )
352
353 const queryParams =
354 paramDescription?.dataTypeIDs.map((dataTypeID) => ({
355 dataTypeID,
356 serializer: this.serializers[dataTypeID],
357 })) ?? []
358
359 const resultFields =
360 resultDescription?.fields.map((field) => ({
361 name: field.name,
362 dataTypeID: field.dataTypeID,
363 parser: this.parsers[field.dataTypeID],
364 })) ?? []
365
366 return { queryParams, resultFields }
367 } finally {
368 await this.#execProtocolNoSync(serializeProtocol.sync(), options)
369 }
370 }
371
372 /**
373 * Execute a transaction

Callers

nothing calls this directly

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected