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

Function getSearchJsonPropertyKey

packages/sql/src/AbstractSqlPlatform.ts:103–117  ·  view source on GitHub ↗
(
    path: string[],
    type: string,
    aliased: boolean,
    value?: unknown,
  )

Source from the content-addressed store, hash-verified

101 }
102
103 override getSearchJsonPropertyKey(
104 path: string[],
105 type: string,
106 aliased: boolean,
107 value?: unknown,
108 ): string | RawQueryFragment {
109 const [a, ...b] = path;
110 const jsonPath = this.quoteValue(`$.${b.map(this.quoteJsonKey).join('.')}`);
111
112 if (aliased) {
113 return raw(alias => `json_extract(${this.quoteIdentifier(`${alias}.${a}`)}, ${jsonPath})`);
114 }
115
116 return raw(`json_extract(${this.quoteIdentifier(a)}, ${jsonPath})`);
117 }
118
119 /**
120 * Quotes a key for use inside a JSON path expression (e.g. `$.key`).

Callers

nothing calls this directly

Calls 5

rawFunction · 0.90
quoteValueMethod · 0.80
joinMethod · 0.65
mapMethod · 0.45
quoteIdentifierMethod · 0.45

Tested by

no test coverage detected