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 }