(opts?: { addIndex?: boolean; parentPath?: string })
| 134 | } |
| 135 | |
| 136 | getPath(opts?: { addIndex?: boolean; parentPath?: string }): string { |
| 137 | // use index on parent only if we are processing to-many relation |
| 138 | const addParentIndex = |
| 139 | this.prop && [ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(this.prop.kind); |
| 140 | const parentPath = |
| 141 | opts?.parentPath ?? this.parent?.getPath({ addIndex: addParentIndex }) ?? Utils.className(this.entityName); |
| 142 | const index = opts?.addIndex && this.index != null ? `[${this.index}]` : ''; |
| 143 | // ignore group operators to allow easier mapping (e.g. for orderBy) |
| 144 | const key = |
| 145 | this.key && !RawQueryFragment.isKnownFragmentSymbol(this.key) && !['$and', '$or', '$not'].includes(this.key) |
| 146 | ? '.' + this.key |
| 147 | : ''; |
| 148 | const ret = parentPath + index + key; |
| 149 | |
| 150 | if (this.isPivotJoin()) { |
| 151 | // distinguish pivot table join from target entity join |
| 152 | return this.getPivotPath(ret); |
| 153 | } |
| 154 | |
| 155 | return ret; |
| 156 | } |
| 157 | |
| 158 | private isPivotJoin(): boolean { |
| 159 | if (!this.key || !this.prop) { |
no test coverage detected