◐ Shell
reader mode source ↗
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
5 changes: 5 additions & 0 deletions src/sqlParser.jison
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ IN return 'IN'
SOUNDS return 'SOUNDS'
LIKE return 'LIKE'
ESCAPE return 'ESCAPE'
REGEXP return 'REGEXP'
IS return 'IS'
UNKNOWN return 'UNKNOWN'
Expand Down Expand Up @@ -343,6 +344,9 @@ case_when_else
case_when
: CASE case_expr_opt when_then_list case_when_else END { $$ = { type: 'CaseWhen', caseExprOpt: $2, whenThenList: $3, else: $4 } }
;
simple_expr_prefix
: '+' simple_expr %prec UPLUS { $$ = { type: 'Prefix', prefix: $1, value: $2 } }
| '-' simple_expr %prec UMINUS { $$ = { type: 'Prefix', prefix: $1, value: $2 } }
Expand All @@ -361,6 +365,7 @@ simple_expr
| EXISTS '(' selectClause ')' { $$ = { type: 'SubQuery', value: $3, hasExists: true } }
| '{' identifier expr '}' { $$ = { type: 'IdentifierExpr', identifier: $2, value: $3 } }
| case_when { $$ = $1 }
;
bit_expr
: simple_expr { $$ = $1 }
8 changes: 8 additions & 0 deletions src/stringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,14 @@ Sql.prototype.travelCaseWhen = function(ast) {
}
this.appendKeyword('end');
};
Sql.prototype.travelPrefix = function(ast) {
this.appendKeyword(ast.prefix);
this.travel(ast.value);
Toggle all file notes Toggle all file annotations