Skip to content

Commit

Permalink
feat($filter): #52, support null value for query.
Browse files Browse the repository at this point in the history
  • Loading branch information
zackyang000 committed Apr 9, 2016
1 parent e810951 commit 15920f7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/parser/filterParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ const validator = {
val = +value;
} else if (stringHelper.isBeginWith(value, "'") && stringHelper.isEndWith(value, "'")) {
val = value.slice(1, -1);
} else if (value === 'null') {
val = value;
} else {
return ({ err: `Syntax error at '${value}'.` });
}
Expand Down Expand Up @@ -91,6 +93,18 @@ export default (query, $filter) => new Promise((resolve, reject) => {
if (conditionArr.length === 1) {
return reject(`Syntax error at '${item}'.`);
}
if (value === 'null') {
switch (odataOperator) {
case 'eq':
query.exists(key, false);
return resolve();
case 'ne':
query.exists(key, true);
return resolve();
default:
break;
}
}
// operator query
switch (odataOperator) {
case 'eq':
Expand Down

0 comments on commit 15920f7

Please sign in to comment.