MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / prepareQuery

Function prepareQuery

packages/sql/src/AbstractSqlConnection.ts:267–284  ·  view source on GitHub ↗
(
    query: string | NativeQueryBuilder | RawQueryFragment,
    params: readonly unknown[] = [],
  )

Source from the content-addressed store, hash-verified

265 }
266
267 private prepareQuery(
268 query: string | NativeQueryBuilder | RawQueryFragment,
269 params: readonly unknown[] = [],
270 ): { query: string; params: readonly unknown[]; formatted: string } {
271 if (query instanceof NativeQueryBuilder) {
272 query = query.toRaw();
273 }
274
275 if (isRaw(query)) {
276 params = query.params;
277 query = query.sql;
278 }
279
280 query = this.config.get('onQuery')(query, params);
281 const formatted = this.platform.formatQuery(query, params);
282
283 return { query, params, formatted };
284 }
285
286 /** Executes a SQL query and returns the result based on the method: `'all'` for rows, `'get'` for single row, `'run'` for affected count. */
287 async execute<T extends QueryResult | EntityData<AnyEntity> | EntityData<AnyEntity>[] = EntityData<AnyEntity>[]>(

Callers

nothing calls this directly

Calls 4

isRawFunction · 0.90
formatQueryMethod · 0.80
getMethod · 0.65
toRawMethod · 0.45

Tested by

no test coverage detected