(type: QueryType, data?: any, cond?: any)
| 3355 | } |
| 3356 | |
| 3357 | protected init(type: QueryType, data?: any, cond?: any): this { |
| 3358 | this.ensureNotFinalized(); |
| 3359 | this.#state.type = type; |
| 3360 | |
| 3361 | if ([QueryType.UPDATE, QueryType.DELETE].includes(type) && Utils.hasObjectKeys(this.#state.cond)) { |
| 3362 | throw new Error( |
| 3363 | `You are trying to call \`qb.where().${type.toLowerCase()}()\`. Calling \`qb.${type.toLowerCase()}()\` before \`qb.where()\` is required.`, |
| 3364 | ); |
| 3365 | } |
| 3366 | |
| 3367 | if (!this.helper.isTableNameAliasRequired(type)) { |
| 3368 | this.#state.fields = undefined; |
| 3369 | } |
| 3370 | |
| 3371 | if (data) { |
| 3372 | if (Utils.isEntity(data)) { |
| 3373 | data = this.em?.getComparator().prepareEntity(data as Entity) ?? serialize(data as Entity); |
| 3374 | } |
| 3375 | |
| 3376 | this.#state.data = this.helper.processData(data, this.#state.flags.has(QueryFlag.CONVERT_CUSTOM_TYPES), false); |
| 3377 | } |
| 3378 | |
| 3379 | if (cond) { |
| 3380 | this.where(cond); |
| 3381 | } |
| 3382 | |
| 3383 | return this; |
| 3384 | } |
| 3385 | |
| 3386 | private getQueryBase(processVirtualEntity: boolean): NativeQueryBuilder { |
| 3387 | const qb = this.platform.createNativeQueryBuilder().setFlags(this.#state.flags); |
no test coverage detected