typeorm 0.3.27-dev.8b76e1a → 0.3.27-dev.96ea431
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/data-source/BaseDataSourceOptions.d.ts +18 -0
- package/browser/data-source/BaseDataSourceOptions.js.map +1 -1
- package/browser/query-builder/QueryBuilder.js +26 -12
- package/browser/query-builder/QueryBuilder.js.map +1 -1
- package/browser/query-builder/SelectQueryBuilder.js +42 -35
- package/browser/query-builder/SelectQueryBuilder.js.map +1 -1
- package/data-source/BaseDataSourceOptions.d.ts +18 -0
- package/data-source/BaseDataSourceOptions.js.map +1 -1
- package/package.json +1 -1
- package/query-builder/QueryBuilder.js +26 -12
- package/query-builder/QueryBuilder.js.map +1 -1
- package/query-builder/SelectQueryBuilder.js +42 -35
- package/query-builder/SelectQueryBuilder.js.map +1 -1
|
@@ -2501,22 +2501,47 @@ export class SelectQueryBuilder extends QueryBuilder {
|
|
|
2501
2501
|
else {
|
|
2502
2502
|
const andConditions = [];
|
|
2503
2503
|
for (const key in where) {
|
|
2504
|
-
|
|
2505
|
-
continue;
|
|
2504
|
+
let parameterValue = where[key];
|
|
2506
2505
|
const propertyPath = embedPrefix ? embedPrefix + "." + key : key;
|
|
2507
2506
|
const column = metadata.findColumnWithPropertyPathStrict(propertyPath);
|
|
2508
2507
|
const embed = metadata.findEmbeddedWithPropertyPath(propertyPath);
|
|
2509
2508
|
const relation = metadata.findRelationWithPropertyPath(propertyPath);
|
|
2510
|
-
if (!embed && !column && !relation)
|
|
2509
|
+
if (!embed && !column && !relation) {
|
|
2511
2510
|
throw new EntityPropertyNotFoundError(propertyPath, metadata);
|
|
2511
|
+
}
|
|
2512
|
+
if (parameterValue === undefined) {
|
|
2513
|
+
const undefinedBehavior = this.connection.options.invalidWhereValuesBehavior
|
|
2514
|
+
?.undefined || "ignore";
|
|
2515
|
+
if (undefinedBehavior === "throw") {
|
|
2516
|
+
throw new TypeORMError(`Undefined value encountered in property '${alias}.${key}' of a where condition. ` +
|
|
2517
|
+
`Set 'invalidWhereValuesBehavior.undefined' to 'ignore' in connection options to skip properties with undefined values.`);
|
|
2518
|
+
}
|
|
2519
|
+
continue;
|
|
2520
|
+
}
|
|
2521
|
+
if (parameterValue === null) {
|
|
2522
|
+
const nullBehavior = this.connection.options.invalidWhereValuesBehavior
|
|
2523
|
+
?.null || "ignore";
|
|
2524
|
+
if (nullBehavior === "ignore") {
|
|
2525
|
+
continue;
|
|
2526
|
+
}
|
|
2527
|
+
else if (nullBehavior === "throw") {
|
|
2528
|
+
throw new TypeORMError(`Null value encountered in property '${alias}.${key}' of a where condition. ` +
|
|
2529
|
+
`To match with SQL NULL, the IsNull() operator must be used. ` +
|
|
2530
|
+
`Set 'invalidWhereValuesBehavior.null' to 'ignore' or 'sql-null' in connection options to skip or handle null values.`);
|
|
2531
|
+
}
|
|
2532
|
+
// 'sql-null' behavior continues to the next logic
|
|
2533
|
+
}
|
|
2512
2534
|
if (column) {
|
|
2513
2535
|
let aliasPath = `${alias}.${propertyPath}`;
|
|
2514
2536
|
if (column.isVirtualProperty && column.query) {
|
|
2515
2537
|
aliasPath = `(${column.query(this.escape(alias))})`;
|
|
2516
2538
|
}
|
|
2539
|
+
if (parameterValue === null) {
|
|
2540
|
+
andConditions.push(`${aliasPath} IS NULL`);
|
|
2541
|
+
continue;
|
|
2542
|
+
}
|
|
2517
2543
|
// const parameterName = alias + "_" + propertyPath.split(".").join("_") + "_" + parameterIndex;
|
|
2518
2544
|
// todo: we need to handle other operators as well?
|
|
2519
|
-
let parameterValue = where[key];
|
|
2520
2545
|
if (InstanceChecker.isEqualOperator(where[key])) {
|
|
2521
2546
|
parameterValue = where[key].value;
|
|
2522
2547
|
}
|
|
@@ -2532,37 +2557,6 @@ export class SelectQueryBuilder extends QueryBuilder {
|
|
|
2532
2557
|
if (this.connection.driver.options.type === "mssql") {
|
|
2533
2558
|
parameterValue = this.connection.driver.parametrizeValues(column, parameterValue);
|
|
2534
2559
|
}
|
|
2535
|
-
// if (parameterValue === null) {
|
|
2536
|
-
// andConditions.push(`${aliasPath} IS NULL`);
|
|
2537
|
-
//
|
|
2538
|
-
// } else if (parameterValue instanceof FindOperator) {
|
|
2539
|
-
// // let parameters: any[] = [];
|
|
2540
|
-
// // if (parameterValue.useParameter) {
|
|
2541
|
-
// // const realParameterValues: any[] = parameterValue.multipleParameters ? parameterValue.value : [parameterValue.value];
|
|
2542
|
-
// // realParameterValues.forEach((realParameterValue, realParameterValueIndex) => {
|
|
2543
|
-
// //
|
|
2544
|
-
// // // don't create parameters for number to prevent max number of variables issues as much as possible
|
|
2545
|
-
// // if (typeof realParameterValue === "number") {
|
|
2546
|
-
// // parameters.push(realParameterValue);
|
|
2547
|
-
// //
|
|
2548
|
-
// // } else {
|
|
2549
|
-
// // this.expressionMap.nativeParameters[parameterName + realParameterValueIndex] = realParameterValue;
|
|
2550
|
-
// // parameterIndex++;
|
|
2551
|
-
// // parameters.push(this.connection.driver.createParameter(parameterName + realParameterValueIndex, parameterIndex - 1));
|
|
2552
|
-
// // }
|
|
2553
|
-
// // });
|
|
2554
|
-
// // }
|
|
2555
|
-
// andConditions.push(
|
|
2556
|
-
// this.createWhereConditionExpression(this.getWherePredicateCondition(aliasPath, parameterValue))
|
|
2557
|
-
// // parameterValue.toSql(this.connection, aliasPath, parameters));
|
|
2558
|
-
// )
|
|
2559
|
-
//
|
|
2560
|
-
// } else {
|
|
2561
|
-
// this.expressionMap.nativeParameters[parameterName] = parameterValue;
|
|
2562
|
-
// parameterIndex++;
|
|
2563
|
-
// const parameter = this.connection.driver.createParameter(parameterName, parameterIndex - 1);
|
|
2564
|
-
// andConditions.push(`${aliasPath} = ${parameter}`);
|
|
2565
|
-
// }
|
|
2566
2560
|
andConditions.push(this.createWhereConditionExpression(this.getWherePredicateCondition(aliasPath, parameterValue)));
|
|
2567
2561
|
// this.conditions.push(`${alias}.${propertyPath} = :${paramName}`);
|
|
2568
2562
|
// this.expressionMap.parameters[paramName] = where[key]; // todo: handle functions and other edge cases
|
|
@@ -2573,6 +2567,19 @@ export class SelectQueryBuilder extends QueryBuilder {
|
|
|
2573
2567
|
andConditions.push(condition);
|
|
2574
2568
|
}
|
|
2575
2569
|
else if (relation) {
|
|
2570
|
+
if (where[key] === null) {
|
|
2571
|
+
const nullBehavior = this.connection.options.invalidWhereValuesBehavior
|
|
2572
|
+
?.null || "ignore";
|
|
2573
|
+
if (nullBehavior === "sql-null") {
|
|
2574
|
+
andConditions.push(`${alias}.${propertyPath} IS NULL`);
|
|
2575
|
+
}
|
|
2576
|
+
else if (nullBehavior === "throw") {
|
|
2577
|
+
throw new TypeORMError(`Null value encountered in property '${alias}.${key}' of a where condition. ` +
|
|
2578
|
+
`Set 'invalidWhereValuesBehavior.null' to 'ignore' or 'sql-null' in connection options to skip or handle null values.`);
|
|
2579
|
+
}
|
|
2580
|
+
// 'ignore' behavior falls through to continue
|
|
2581
|
+
continue;
|
|
2582
|
+
}
|
|
2576
2583
|
// if all properties of where are undefined we don't need to join anything
|
|
2577
2584
|
// this can happen when user defines map with conditional queries inside
|
|
2578
2585
|
if (typeof where[key] === "object") {
|