From 4ccb08cb49216ed785b44c83f7e19d17c1082f5a Mon Sep 17 00:00:00 2001 From: COOL Date: Sat, 18 Jan 2025 18:22:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=80=BC=E4=B8=BA=E7=A9=BA=E4=B8=8D=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=AC=AC=E4=B8=80=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- typeorm/browser/query-builder/SelectQueryBuilder.js | 10 +++++++--- typeorm/query-builder/SelectQueryBuilder.js | 11 ++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/typeorm/browser/query-builder/SelectQueryBuilder.js b/typeorm/browser/query-builder/SelectQueryBuilder.js index c78a50f..8408256 100644 --- a/typeorm/browser/query-builder/SelectQueryBuilder.js +++ b/typeorm/browser/query-builder/SelectQueryBuilder.js @@ -2462,8 +2462,8 @@ export class SelectQueryBuilder extends QueryBuilder { else { let andConditions = []; for (let key in where) { - if (where[key] === undefined || where[key] === null) - continue; + // if (where[key] === undefined || where[key] === null) + // continue; const propertyPath = embedPrefix ? embedPrefix + "." + key : key; const column = metadata.findColumnWithPropertyPathStrict(propertyPath); const embed = metadata.findEmbeddedWithPropertyPath(propertyPath); @@ -2518,7 +2518,11 @@ export class SelectQueryBuilder extends QueryBuilder { // const parameter = this.connection.driver.createParameter(parameterName, parameterIndex - 1); // andConditions.push(`${aliasPath} = ${parameter}`); // } - andConditions.push(this.createWhereConditionExpression(this.getWherePredicateCondition(aliasPath, parameterValue))); + if (parameterValue === undefined || parameterValue === null) { + andConditions.push(`${aliasPath} IS NULL`); + }else{ + andConditions.push(this.createWhereConditionExpression(this.getWherePredicateCondition(aliasPath, parameterValue))); + } // this.conditions.push(`${alias}.${propertyPath} = :${paramName}`); // this.expressionMap.parameters[paramName] = where[key]; // todo: handle functions and other edge cases } diff --git a/typeorm/query-builder/SelectQueryBuilder.js b/typeorm/query-builder/SelectQueryBuilder.js index 8eda00e..5ce8a01 100644 --- a/typeorm/query-builder/SelectQueryBuilder.js +++ b/typeorm/query-builder/SelectQueryBuilder.js @@ -2465,8 +2465,8 @@ class SelectQueryBuilder extends QueryBuilder_1.QueryBuilder { else { let andConditions = []; for (let key in where) { - if (where[key] === undefined || where[key] === null) - continue; + // if (where[key] === undefined || where[key] === null) + // continue; const propertyPath = embedPrefix ? embedPrefix + "." + key : key; const column = metadata.findColumnWithPropertyPathStrict(propertyPath); const embed = metadata.findEmbeddedWithPropertyPath(propertyPath); @@ -2490,6 +2490,11 @@ class SelectQueryBuilder extends QueryBuilder_1.QueryBuilder { : (parameterValue = ApplyValueTransformers_1.ApplyValueTransformers.transformTo(column.transformer, parameterValue)); } + if (parameterValue === undefined || parameterValue === null) { + andConditions.push(`${aliasPath} IS NULL`); + }else{ + andConditions.push(this.createWhereConditionExpression(this.getWherePredicateCondition(aliasPath, parameterValue))); + } // if (parameterValue === null) { // andConditions.push(`${aliasPath} IS NULL`); // @@ -2521,7 +2526,7 @@ class SelectQueryBuilder extends QueryBuilder_1.QueryBuilder { // const parameter = this.connection.driver.createParameter(parameterName, parameterIndex - 1); // andConditions.push(`${aliasPath} = ${parameter}`); // } - andConditions.push(this.createWhereConditionExpression(this.getWherePredicateCondition(aliasPath, parameterValue))); + // andConditions.push(this.createWhereConditionExpression(this.getWherePredicateCondition(aliasPath, parameterValue))); // this.conditions.push(`${alias}.${propertyPath} = :${paramName}`); // this.expressionMap.parameters[paramName] = where[key]; // todo: handle functions and other edge cases }