Skip to content
3 changes: 1 addition & 2 deletions src/query-builder/QueryBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,7 @@ export abstract class QueryBuilder<Entity extends ObjectLiteral> {
} else {
if (typeof entityTarget === "string") {
const isSubquery =
entityTarget.substr(0, 1) === "(" &&
entityTarget.substr(-1) === ")"
entityTarget.startsWith("(") && entityTarget.endsWith(")")

return this.expressionMap.createAlias({
type: "from",
Expand Down
6 changes: 3 additions & 3 deletions src/query-builder/SelectQueryBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3221,9 +3221,9 @@ export class SelectQueryBuilder<Entity extends ObjectLiteral>

if (this.conditions.length)
this.andWhere(
this.conditions.substr(0, 1) !== "("
? "(" + this.conditions + ")"
: this.conditions,
this.conditions.startsWith("(")
? this.conditions
: `(${this.conditions})`,
) // temporary and where and braces
}

Expand Down
Loading