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

Method prefix

packages/sql/src/query/QueryBuilderHelper.ts:1089–1125  ·  view source on GitHub ↗
(field: string, always = false, quote = false, idx?: number)

Source from the content-addressed store, hash-verified

1087 }
1088
1089 private prefix(field: string, always = false, quote = false, idx?: number): string {
1090 let ret: string;
1091
1092 if (!this.isPrefixed(field)) {
1093 // For TPT inheritance, resolve the correct alias for this property
1094 const tptAlias = this.getTPTAliasForProperty(field, this.#alias);
1095 const alias = always ? (quote ? tptAlias : this.#platform.quoteIdentifier(tptAlias)) + '.' : '';
1096 const fieldName = this.fieldName(field, tptAlias, always, idx);
1097
1098 if (isRaw(fieldName)) {
1099 return fieldName.sql;
1100 }
1101
1102 ret = alias + fieldName;
1103 } else {
1104 const [a, ...rest] = field.split('.');
1105 const f = rest.join('.');
1106 // For TPT inheritance, resolve the correct alias for this property
1107 // Only apply TPT resolution when `a` is an actual table alias (in aliasMap),
1108 // not when it's an embedded property name like 'profile1.identity.links'
1109 const isTableAlias = !!this.#aliasMap[a];
1110 const resolvedAlias = isTableAlias ? this.getTPTAliasForProperty(f, a) : a;
1111 const fieldName = this.fieldName(f, resolvedAlias, always, idx);
1112
1113 if (isRaw(fieldName)) {
1114 return fieldName.sql;
1115 }
1116
1117 ret = resolvedAlias + '.' + fieldName;
1118 }
1119
1120 if (quote) {
1121 return this.#platform.quoteIdentifier(ret);
1122 }
1123
1124 return ret;
1125 }
1126
1127 private appendGroupCondition(
1128 type: QueryType,

Callers 1

mapperMethod · 0.95

Calls 6

isPrefixedMethod · 0.95
fieldNameMethod · 0.95
isRawFunction · 0.90
joinMethod · 0.65
quoteIdentifierMethod · 0.45

Tested by

no test coverage detected