| 585 | * ``` |
| 586 | */ |
| 587 | export class QueryBuilder< |
| 588 | Entity extends object = AnyEntity, |
| 589 | RootAlias extends string = never, |
| 590 | Hint extends string = never, |
| 591 | Context extends object = never, |
| 592 | RawAliases extends string = never, |
| 593 | Fields extends string = '*', |
| 594 | CTEs extends Record<string, object> = {}, |
| 595 | > implements Subquery { |
| 596 | declare readonly __subquery: true; |
| 597 | |
| 598 | #state: QBState<Entity> = QueryBuilder.createDefaultState<Entity>(); |
| 599 | #helper?: QueryBuilderHelper; |
| 600 | #query?: { sql?: string; params?: readonly unknown[]; qb: NativeQueryBuilder }; |
| 601 | #abortOptions?: AbortQueryOptions; |
| 602 | |
| 603 | /** @internal */ |
| 604 | static createDefaultState<T extends object>(): QBState<T> { |
| 605 | return { |
| 606 | aliasCounter: 0, |
| 607 | explicitAlias: false, |
| 608 | populateHintFinalized: false, |
| 609 | joins: {}, |
| 610 | cond: {}, |
| 611 | orderBy: [], |
| 612 | groupBy: [], |
| 613 | having: {}, |
| 614 | comments: [], |
| 615 | hintComments: [], |
| 616 | subQueries: {}, |
| 617 | aliases: {}, |
| 618 | tptAlias: {}, |
| 619 | ctes: [], |
| 620 | tptJoinsApplied: false, |
| 621 | autoJoinedPaths: [], |
| 622 | populate: [], |
| 623 | populateMap: {}, |
| 624 | flags: new Set([QueryFlag.CONVERT_CUSTOM_TYPES]), |
| 625 | finalized: false, |
| 626 | joinedProps: new Map(), |
| 627 | }; |
| 628 | } |
| 629 | |
| 630 | get mainAlias(): Alias<Entity> { |
| 631 | this.ensureFromClause(); |
| 632 | return this.#state.mainAlias!; |
| 633 | } |
| 634 | |
| 635 | get alias(): string { |
| 636 | return this.mainAlias.aliasName; |
| 637 | } |
| 638 | |
| 639 | get helper(): QueryBuilderHelper { |
| 640 | this.ensureFromClause(); |
| 641 | return this.#helper!; |
| 642 | } |
| 643 | |
| 644 | get type(): QueryType { |
nothing calls this directly
no test coverage detected