Fix bug with where queries
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
bb291c207d
commit
c48212cc17
@ -490,7 +490,7 @@ export class CollectionQuery extends Query {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _where: IQueryWhereArray[] = [];
|
private _where: IQueryWhereArray[];
|
||||||
public set where(value: IQueryWhere[]) {
|
public set where(value: IQueryWhere[]) {
|
||||||
const invalidWhere = new QueryError("Invalid Where");
|
const invalidWhere = new QueryError("Invalid Where");
|
||||||
if (!Array.isArray(value)) throw invalidWhere;
|
if (!Array.isArray(value)) throw invalidWhere;
|
||||||
@ -573,6 +573,7 @@ export class CollectionQuery extends Query {
|
|||||||
while (parts.length > 0) {
|
while (parts.length > 0) {
|
||||||
let seg = parts.shift();
|
let seg = parts.shift();
|
||||||
|
|
||||||
|
console.log(data, seg, data[seg]);
|
||||||
d = data[seg];
|
d = data[seg];
|
||||||
if (d === undefined || d === null) break; // Undefined/Null has no other fields!
|
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 {
|
private _fitsWhere(data: any): boolean {
|
||||||
if (this._where.length > 0) {
|
if (this._where && this._where.length > 0) {
|
||||||
return this._where.every(([fieldPath, opStr, value]) => {
|
return this._where.every(([fieldPath, opStr, value]) => {
|
||||||
let val = this._getFieldValue(data, fieldPath);
|
let val = this._getFieldValue(data, fieldPath);
|
||||||
switch (opStr) {
|
switch (opStr) {
|
||||||
|
Reference in New Issue
Block a user