Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
feat(gql): add date support to gql
Browse files Browse the repository at this point in the history
Closes #719
  • Loading branch information
Shane Wilson committed Mar 29, 2016
1 parent fd28fab commit e306bfb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 4 additions & 2 deletions app/scripts/components/gql/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,11 @@ module ngApp.components.gql {
$scope.ddItems = _.filter(
GqlService.parseGrammarError($scope.parts.needle, $scope.error),
(item: IDdItem): boolean => {
var op: IDdItem = mapping[$scope.parts.op.toLowerCase()] || {};
if ((op.type || '') === 'long' || (op.full || '').toString().indexOf('datetime') != -1) {
var op: IDdItem = mapping[$scope.parts.op.toLowerCase()] || {};
if (['long', 'integer'].indexOf(op.type || '') !== -1) {
return [T.EQ, T.NE, T.GT, T.GTE, T.LT, T.LTE, T.IS, T.NOT].indexOf(item.full.toString()) != -1
} else if ((op.full || '').toString().indexOf('datetime') != -1) {
return [T.GT, T.GTE, T.LT, T.LTE, T.IS, T.NOT].indexOf(item.full.toString()) != -1
} else if (op.type === 'string') {
return [T.EQ, T.NE, T.IN, T.EXCLUDE, T.IS, T.NOT].indexOf(item.full.toString()) != -1
} else {
Expand Down
11 changes: 9 additions & 2 deletions gql.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ ListExpr
}

Comparable
= INTEGER
= DATE
/ INTEGER

Fields
= x:Field xs:FieldsRest* { return [x].concat(xs); }
Expand All @@ -121,6 +122,7 @@ Term "term"
= UNQUOTED_STRING
/ QUOTED_STRING
/ INTEGER


// Operators
GroupOp
Expand All @@ -142,6 +144,7 @@ CompareOp
DIGIT "number" = [0-9]
INTEGER = $DIGIT+
REAL = DIGIT* "." DIGIT+
DASH = "-"
COMMA "," = ","
COLON ":" = ":"
EQUAL "=" = "="
Expand Down Expand Up @@ -176,7 +179,11 @@ UNQUOTED_STRING
}
QUOTED_STRING
= DBLQ s:$[^"]+ DBLQ { return s; }

DATE
= x:(DIGIT DIGIT DIGIT DIGIT DASH DIGIT DIGIT DASH DIGIT DIGIT)
{
return x.join('');
}
// Extra
_
= ( WhiteSpace / NewLine )
Expand Down

0 comments on commit e306bfb

Please sign in to comment.