(meta: EntityMetadata<T>)
| 2959 | } |
| 2960 | |
| 2961 | private fromVirtual<T extends object>(meta: EntityMetadata<T>): string { |
| 2962 | if (typeof meta.expression === 'string') { |
| 2963 | return `(${meta.expression}) as ${this.platform.quoteIdentifier(this.alias)}`; |
| 2964 | } |
| 2965 | |
| 2966 | const res = meta.expression!(this.em, this.#state.cond as any, {}); |
| 2967 | |
| 2968 | if (typeof res === 'string') { |
| 2969 | return `(${res}) as ${this.platform.quoteIdentifier(this.alias)}`; |
| 2970 | } |
| 2971 | |
| 2972 | if (res instanceof QueryBuilder) { |
| 2973 | return `(${res.getFormattedQuery()}) as ${this.platform.quoteIdentifier(this.alias)}`; |
| 2974 | } |
| 2975 | |
| 2976 | if (isRaw(res)) { |
| 2977 | const query = this.platform.formatQuery(res.sql, res.params); |
| 2978 | return `(${query}) as ${this.platform.quoteIdentifier(this.alias)}`; |
| 2979 | } |
| 2980 | |
| 2981 | /* v8 ignore next */ |
| 2982 | return res as unknown as string; |
| 2983 | } |
| 2984 | |
| 2985 | /** |
| 2986 | * Adds a join from a property object. Used internally for TPT joins where the property |
no test coverage detected