isnull, is distinct from
This commit is contained in:
parent
0c286e0edf
commit
8051aa73bb
2 changed files with 82 additions and 2 deletions
|
@ -154,3 +154,71 @@ end $$;
|
||||||
(return_statement
|
(return_statement
|
||||||
(number)))))
|
(number)))))
|
||||||
(dollar_quote))))
|
(dollar_quote))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
if is not null
|
||||||
|
================================================================================
|
||||||
|
do $$ begin
|
||||||
|
if foo is not null then select 1; end if;
|
||||||
|
end $$;
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(do_block
|
||||||
|
(block
|
||||||
|
(dollar_quote)
|
||||||
|
(body
|
||||||
|
(if_statement
|
||||||
|
(op_expression
|
||||||
|
(identifier)
|
||||||
|
(comparison_null))
|
||||||
|
(select_statement
|
||||||
|
(select_item
|
||||||
|
(number)))))
|
||||||
|
(dollar_quote))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
if is not distinct from
|
||||||
|
================================================================================
|
||||||
|
do $$ begin
|
||||||
|
if foo is not distinct from bar then select 1; end if;
|
||||||
|
end $$;
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(do_block
|
||||||
|
(block
|
||||||
|
(dollar_quote)
|
||||||
|
(body
|
||||||
|
(if_statement
|
||||||
|
(op_expression
|
||||||
|
(identifier)
|
||||||
|
(comparison_kw)
|
||||||
|
(identifier))
|
||||||
|
(select_statement
|
||||||
|
(select_item
|
||||||
|
(number)))))
|
||||||
|
(dollar_quote))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
if is distinct from
|
||||||
|
================================================================================
|
||||||
|
do $$ begin
|
||||||
|
if foo is distinct from bar then select 1; end if;
|
||||||
|
end $$;
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(do_block
|
||||||
|
(block
|
||||||
|
(dollar_quote)
|
||||||
|
(body
|
||||||
|
(if_statement
|
||||||
|
(op_expression
|
||||||
|
(identifier)
|
||||||
|
(comparison_kw)
|
||||||
|
(identifier))
|
||||||
|
(select_statement
|
||||||
|
(select_item
|
||||||
|
(number)))))
|
||||||
|
(dollar_quote))))
|
||||||
|
|
16
grammar.js
16
grammar.js
|
@ -757,7 +757,8 @@ module.exports = grammar({
|
||||||
prec.left(6, seq($._value_expression, $.other_op, $._value_expression)),
|
prec.left(6, seq($._value_expression, $.other_op, $._value_expression)),
|
||||||
// between in like ilike similar
|
// between in like ilike similar
|
||||||
prec.left(4, seq($._value_expression, $.comparison_op, $._value_expression,)),
|
prec.left(4, seq($._value_expression, $.comparison_op, $._value_expression,)),
|
||||||
// is isnull notnull
|
prec.left(3, seq($._value_expression, $.comparison_kw, $._value_expression,)),
|
||||||
|
prec.left(3, seq($._value_expression, $.comparison_null)),
|
||||||
prec.right(2, seq($.not, $._value_expression)),
|
prec.right(2, seq($.not, $._value_expression)),
|
||||||
prec.left(1, seq($._value_expression, choice($.and, $.or), $._value_expression,)),
|
prec.left(1, seq($._value_expression, choice($.and, $.or), $._value_expression,)),
|
||||||
),
|
),
|
||||||
|
@ -766,8 +767,19 @@ module.exports = grammar({
|
||||||
|
|
||||||
// TODO(chrde): https://www.postgresql.org/docs/13/sql-syntax-lexical.html
|
// TODO(chrde): https://www.postgresql.org/docs/13/sql-syntax-lexical.html
|
||||||
comparison_op: $ => choice("<", ">", "=", "<=", ">=", "<>", "!="),
|
comparison_op: $ => choice("<", ">", "=", "<=", ">=", "<>", "!="),
|
||||||
|
comparison_null: $ => choice(
|
||||||
|
kw("is null"),
|
||||||
|
kw("isnull"),
|
||||||
|
kw("is not null"),
|
||||||
|
kw("notnull"),
|
||||||
|
),
|
||||||
|
comparison_kw: $ => choice(
|
||||||
|
kw("is"),
|
||||||
|
kw("is distinct from"),
|
||||||
|
kw("is not distinct from")
|
||||||
|
),
|
||||||
// TODO(chrde): this should be a regex
|
// TODO(chrde): this should be a regex
|
||||||
other_op: $ => choice("||"),
|
other_op: $ => choice("||", "<@", "@>", "<<", ">>", "&&", "&<", "&>", "-|-"),
|
||||||
cast: $ => "::",
|
cast: $ => "::",
|
||||||
minus: $ => "-",
|
minus: $ => "-",
|
||||||
plus: $ => "+",
|
plus: $ => "+",
|
||||||
|
|
Loading…
Reference in a new issue