Fix bug with where queries
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Fabian Stamm 2020-08-15 20:33:18 +02:00
parent bb291c207d
commit c48212cc17
1 changed files with 3 additions and 2 deletions

View File

@ -490,7 +490,7 @@ export class CollectionQuery extends Query {
}
}
private _where: IQueryWhereArray[] = [];
private _where: IQueryWhereArray[];
public set where(value: IQueryWhere[]) {
const invalidWhere = new QueryError("Invalid Where");
if (!Array.isArray(value)) throw invalidWhere;
@ -573,6 +573,7 @@ export class CollectionQuery extends Query {
while (parts.length > 0) {
let seg = parts.shift();
console.log(data, seg, data[seg]);
d = data[seg];
if (d === undefined || d === null) break; // Undefined/Null has no other fields!
}
@ -580,7 +581,7 @@ export class CollectionQuery extends Query {
}
private _fitsWhere(data: any): boolean {
if (this._where.length > 0) {
if (this._where && this._where.length > 0) {
return this._where.every(([fieldPath, opStr, value]) => {
let val = this._getFieldValue(data, fieldPath);
switch (opStr) {