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

Method addPropertyJoin

packages/sql/src/query/QueryBuilder.ts:2991–3007  ·  view source on GitHub ↗

* Adds a join from a property object. Used internally for TPT joins where the property * is synthetic (not in entity.properties) but defined on metadata (e.g., tptParentProp). * The caller must create the alias first via createAlias(). * @internal

(
    prop: EntityProperty,
    ownerAlias: string,
    alias: string,
    type: JoinType,
    path: string,
    schema?: string,
  )

Source from the content-addressed store, hash-verified

2989 * @internal
2990 */
2991 addPropertyJoin(
2992 prop: EntityProperty,
2993 ownerAlias: string,
2994 alias: string,
2995 type: JoinType,
2996 path: string,
2997 schema?: string,
2998 ): string {
2999 schema ??= prop.targetMeta?.schema === '*' ? '*' : this.driver.getSchemaName(prop.targetMeta);
3000 const key = `[tpt]${ownerAlias}#${alias}`;
3001 this.#state.joins[key] =
3002 prop.kind === ReferenceKind.MANY_TO_ONE
3003 ? this.helper.joinManyToOneReference(prop, ownerAlias, alias, type, {}, schema)
3004 : this.helper.joinOneToReference(prop, ownerAlias, alias, type, {}, schema);
3005 this.#state.joins[key].path = path;
3006 return key;
3007 }
3008
3009 private joinReference(
3010 field: string | RawQueryFragment | NativeQueryBuilder | QueryBuilder,

Callers 4

applyTPTJoinsMethod · 0.95

Calls 3

joinOneToReferenceMethod · 0.80
getSchemaNameMethod · 0.65

Tested by

no test coverage detected