Skip to content

Question: QueryBuilder #920

@iz-iznogood

Description

@iz-iznogood

Hi I checked the functionality that is provided by the Brackets class to assist the creation of complex conditions and it is awesome.
But there are a few issues

  1. Brackets is not exported, so it can not be used
  2. How can I use this in Join methods (innerJoin, joinandSelect etc) since we might have complex predicates there too.
  3. If (2) is not possible, can I create another queryBuilder to assist on the creation of the complex statement and then extract the SQL to use it in join method ?

Regarding (3) I noticed this code inside query builder

    protected computeWhereParameter(where: string|((qb: this) => string)|Brackets) {
        if (typeof where === "string")
            return where;

        if (where instanceof Brackets) {
            const whereQueryBuilder = this.createQueryBuilder();
            where.whereFactory(whereQueryBuilder as any);
            const whereString = whereQueryBuilder.createWhereExpressionString();
            this.setParameters(whereQueryBuilder.getParameters());
            return whereString ? "(" + whereString + ")" : "";
        }

        return where(this);
    }

Is this the appropriate way to create queryBuilders to construct partial statements and then somehow merge them with the main query builder ?

Can you direct me to such code if exists, since I create queries dynamically and I need such functionality in many places

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions