MCPcopy
hub / github.com/prisma/prisma / query

Method query

packages/query-plan-executor/src/logic/app.ts:85–120  ·  view source on GitHub ↗

* Executes a query plan and returns the result. * * @param queryPlan - The query plan to execute * @param scope - Placeholder values for the query * @param comments - Pre-computed SQL commenter tags from the client * @param resourceLimits - Resource limits for the query * @param tr

(
    queryPlan: QueryPlanNode,
    scope: Record<string, unknown>,
    comments: Record<string, string> | undefined,
    resourceLimits: ResourceLimits,
    transactionId: string | null,
  )

Source from the content-addressed store, hash-verified

83 * @param transactionId - Transaction ID if running within a transaction
84 */
85 async query(
86 queryPlan: QueryPlanNode,
87 scope: Record<string, unknown>,
88 comments: Record<string, string> | undefined,
89 resourceLimits: ResourceLimits,
90 transactionId: string | null,
91 ): Promise<unknown> {
92 const queryable =
93 transactionId !== null ? await this.#transactionManager.getTransaction({ id: transactionId }, 'query') : this.#db
94
95 // Create constant commenter plugin if comments were provided
96 const sqlCommenter: QueryInterpreterSqlCommenter | undefined =
97 comments && Object.keys(comments).length > 0
98 ? {
99 plugins: [() => comments],
100 // For pre-computed comments, we use a placeholder queryInfo since the actual
101 // query info was already used on the client side to compute the comments
102 queryInfo: { type: 'single', action: 'queryRaw', query: {} },
103 }
104 : undefined
105
106 const result = await Promise.race([
107 this.#interpreter.run(queryPlan, {
108 queryable,
109 transactionManager:
110 transactionId === null ? { enabled: true, manager: this.#transactionManager } : { enabled: false },
111 scope,
112 sqlCommenter,
113 }),
114 timers.setTimeout(resourceLimits.queryTimeout.total('milliseconds'), undefined, { ref: false }).then(() => {
115 throw new ResourceLimitError('Query timeout exceeded')
116 }),
117 ])
118
119 return normalizeJsonProtocolValues(result)
120 }
121
122 /**
123 * Starts a new transaction.

Callers 15

__database.tsFile · 0.45
__database.tsFile · 0.45
__database.tsFile · 0.45
__database.tsFile · 0.45
setupPostgresFunction · 0.45
tearDownPostgresFunction · 0.45
setupMSSQLFunction · 0.45
setupMysqlFunction · 0.45
tearDownMysqlFunction · 0.45
main.tsFile · 0.45
getExtendedClientFunction · 0.45
commitMethod · 0.45

Calls 4

getTransactionMethod · 0.80
runMethod · 0.65
thenMethod · 0.65

Tested by 1

queryRawFunction · 0.36