in, between..
This commit is contained in:
parent
d6a6775598
commit
48e0701909
2 changed files with 48 additions and 2 deletions
|
@ -211,6 +211,50 @@ SELECT 'hello' || 'quote''s everywh''ere';
|
||||||
(other_op)
|
(other_op)
|
||||||
(string)))))
|
(string)))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
contains_op
|
||||||
|
================================================================================
|
||||||
|
SELECT
|
||||||
|
1 in (1, 2),
|
||||||
|
'one' in ('one', 'two'),
|
||||||
|
2 between 4 and 8,
|
||||||
|
'foo' like '%oo',
|
||||||
|
'foo' ilike '%oo';
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(select_statement
|
||||||
|
(select_item
|
||||||
|
(op_expression
|
||||||
|
(number)
|
||||||
|
(contains_op)
|
||||||
|
(number)
|
||||||
|
(number)))
|
||||||
|
(select_item
|
||||||
|
(op_expression
|
||||||
|
(string)
|
||||||
|
(contains_op)
|
||||||
|
(string)
|
||||||
|
(string)))
|
||||||
|
(select_item
|
||||||
|
(op_expression
|
||||||
|
(op_expression
|
||||||
|
(number)
|
||||||
|
(contains_op)
|
||||||
|
(number))
|
||||||
|
(and)
|
||||||
|
(number)))
|
||||||
|
(select_item
|
||||||
|
(op_expression
|
||||||
|
(string)
|
||||||
|
(contains_op)
|
||||||
|
(string)))
|
||||||
|
(select_item
|
||||||
|
(op_expression
|
||||||
|
(string)
|
||||||
|
(contains_op)
|
||||||
|
(string)))))
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
is null, isnull, is not null, notnull
|
is null, isnull, is not null, notnull
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
|
@ -729,7 +729,7 @@ module.exports = grammar({
|
||||||
$.null,
|
$.null,
|
||||||
$.star,
|
$.star,
|
||||||
seq("(", $.select_statement, ")"),
|
seq("(", $.select_statement, ")"),
|
||||||
seq("(", $._value_expression, ")"),
|
seq("(", commaSep1($._value_expression), ")"),
|
||||||
$.function_call,
|
$.function_call,
|
||||||
$.op_expression,
|
$.op_expression,
|
||||||
$.time_expression,
|
$.time_expression,
|
||||||
|
@ -786,7 +786,7 @@ module.exports = grammar({
|
||||||
prec.left(8, seq($._value_expression, choice("*", "/", "%"), $._value_expression,)),
|
prec.left(8, seq($._value_expression, choice("*", "/", "%"), $._value_expression,)),
|
||||||
prec.left(7, seq($._value_expression, choice("-", "+"), $._value_expression,)),
|
prec.left(7, seq($._value_expression, choice("-", "+"), $._value_expression,)),
|
||||||
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
|
prec.left(5, seq($._value_expression, $.contains_op, $._value_expression,)),
|
||||||
prec.left(4, seq($._value_expression, $.comparison_op, $._value_expression,)),
|
prec.left(4, seq($._value_expression, $.comparison_op, $._value_expression,)),
|
||||||
prec.left(3, seq($._value_expression, $.comparison_kw, $._value_expression,)),
|
prec.left(3, seq($._value_expression, $.comparison_kw, $._value_expression,)),
|
||||||
prec.left(3, seq($._value_expression, $.comparison_null)),
|
prec.left(3, seq($._value_expression, $.comparison_null)),
|
||||||
|
@ -798,6 +798,8 @@ 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("<", ">", "=", "<=", ">=", "<>", "!="),
|
||||||
|
// TODO(chrde): is there a better name other than `contains_op`?
|
||||||
|
contains_op: $ => choice(kw("between"), kw("in"), kw("like"), kw("ilike")),
|
||||||
comparison_null: $ => choice(
|
comparison_null: $ => choice(
|
||||||
kw("is null"),
|
kw("is null"),
|
||||||
kw("isnull"),
|
kw("isnull"),
|
||||||
|
|
Loading…
Reference in a new issue