Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/keywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export const sqlKeywords = [

// added manually
, "PRECISION"
];
, "UNKNOWN"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not completely sure if this should be here.

];
2 changes: 1 addition & 1 deletion src/syntax/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ export interface ExprCast extends PGNode {
}


export type UnaryOperator = '+' | '-' | 'NOT' | 'IS NULL' | 'IS NOT NULL' | 'IS TRUE' | 'IS FALSE' | 'IS NOT TRUE' | 'IS NOT FALSE';
export type UnaryOperator = '+' | '-' | 'NOT' | 'IS NULL' | 'IS NOT NULL' | 'IS TRUE' | 'IS FALSE' | 'IS NOT TRUE' | 'IS NOT FALSE' | 'IS UNKNOWN' | 'IS NOT UNKNOWN';
export interface ExprUnary extends PGNode {
type: 'unary';
operand: Expr;
Expand Down
3 changes: 2 additions & 1 deletion src/syntax/expr.ne
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ expr_star -> star {% x => track(x, { type: 'ref', name: '*' }) %}
expr_is
-> (expr_is | expr_paren) (%kw_isnull | %kw_is %kw_null) {% x => track(x, { type: 'unary', op: 'IS NULL', operand: unwrap(x[0]) }) %}
| (expr_is | expr_paren) (%kw_notnull | %kw_is kw_not_null) {% x => track(x, { type: 'unary', op: 'IS NOT NULL', operand: unwrap(x[0])}) %}
| (expr_is | expr_paren) %kw_is %kw_not:? (%kw_true | %kw_false) {% x => track(x, {
| (expr_is | expr_paren) %kw_is %kw_not:? (%kw_true | %kw_false | %kw_unknown) {% x => track(x, {
type: 'unary',
op: 'IS ' + flattenStr([x[2], x[3]])
.join(' ')
Expand Down Expand Up @@ -249,6 +249,7 @@ expr_primary
| value_keyword {% x => track(x, {type: 'keyword', keyword: toStr(x) }) %}
| %qparam {% x => track(x, { type: 'parameter', name: toStr(x[0]) }) %}
| %kw_default {% x => track(x, { type: 'default'}) %}
| %kw_unknown {% x => track(x, { type: 'unknown' }) %}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not completely sure if this should be here.



# LIKE-kind operators
Expand Down
26 changes: 25 additions & 1 deletion src/syntax/expr.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,30 @@ line`,
operand: { type: 'ref', name: 'a' }
});

checkTreeExpr('a isnull', {
type: 'unary',
op: 'IS NULL',
operand: { type: 'ref', name: 'a' }
});

checkTreeExpr('a notnull', {
type: 'unary',
op: 'IS NOT NULL',
operand: { type: 'ref', name: 'a' }
});

checkTreeExpr('a is unknown', {
type: 'unary',
op: 'IS UNKNOWN',
operand: { type: 'ref', name: 'a' }
});

checkTreeExpr('a is not unknown', {
type: 'unary',
op: 'IS NOT UNKNOWN',
operand: { type: 'ref', name: 'a' }
});

});


Expand Down Expand Up @@ -1635,4 +1659,4 @@ line`,
args: [],
});
})
});
});