tree-sitter-plpgsql/test/corpus/select_statement/value_expression.txt

353 lines
9.3 KiB
Text
Raw Permalink Normal View History

2021-08-28 13:46:32 +03:00
================================================================================
string
================================================================================
SELECT 'hello';
--------------------------------------------------------------------------------
(source_file
(select_statement
(select_item
(string))))
================================================================================
nested select
================================================================================
SELECT (SELECT 'hello');
--------------------------------------------------------------------------------
(source_file
(select_statement
(select_item
(select_statement
(select_item
(string))))))
================================================================================
many
================================================================================
SELECT 1234, -25, TRUE, FALSE, NULL, *;
--------------------------------------------------------------------------------
(source_file
(select_statement
(select_item
(number))
(select_item
2021-09-01 18:47:14 +03:00
(number))
2021-08-28 13:46:32 +03:00
(select_item
(true))
(select_item
(false))
(select_item
(null))
(select_item
(star))))
================================================================================
identifiers
================================================================================
SELECT foo, foo.bar;
--------------------------------------------------------------------------------
(source_file
(select_statement
(select_item
(identifier))
(select_item
(identifier))))
2021-09-02 20:54:27 +03:00
================================================================================
arrays
================================================================================
SELECT
ARRAY[],
array[1, 2],
array[array[1, 2], array[3, 4]],
array[]::integer[];
--------------------------------------------------------------------------------
(source_file
(select_statement
(select_item
(array_constructor))
(select_item
(array_constructor
(number)
(number)))
(select_item
(array_constructor
(array_constructor
(number)
(number))
(array_constructor
(number)
(number))))
(select_item
(op_expression
(array_constructor)
(cast)
(identifier)))))
2021-08-28 13:46:32 +03:00
================================================================================
binary_expression
================================================================================
SELECT a + b - c / d * e % f;
--------------------------------------------------------------------------------
(source_file
(select_statement
(select_item
(op_expression
(op_expression
(identifier)
(identifier))
(op_expression
(op_expression
(op_expression
(identifier)
(identifier))
(identifier))
(identifier))))))
================================================================================
unary prec over binary
================================================================================
SELECT -22 + - (5 + 1);
--------------------------------------------------------------------------------
(source_file
(select_statement
(select_item
(op_expression
2021-09-01 18:47:14 +03:00
(number)
2021-08-28 13:46:32 +03:00
(op_expression
(minus)
(op_expression
(number)
(number)))))))
================================================================================
nested parens
================================================================================
SELECT ((((24 + 24))));
--------------------------------------------------------------------------------
(source_file
(select_statement
(select_item
(op_expression
(number)
(number)))))
================================================================================
logical expressions
================================================================================
SELECT 1 - 2 AND TRUE OR (5 = 2);
--------------------------------------------------------------------------------
(source_file
(select_statement
(select_item
(op_expression
(op_expression
(op_expression
(number)
(number))
(and)
(true))
(or)
(op_expression
(number)
(comparison_op)
(number))))))
================================================================================
function call
================================================================================
SELECT foo.bar(param) + baz();
--------------------------------------------------------------------------------
(source_file
(select_statement
(select_item
(op_expression
(function_call
(identifier)
(identifier))
(function_call
(identifier))))))
================================================================================
nested function call
================================================================================
SELECT coalesce(null, nullif(false, true), ops.my_fn(5));
--------------------------------------------------------------------------------
(source_file
(select_statement
(select_item
(function_call
(identifier)
(null)
(function_call
(identifier)
(false)
(true))
(function_call
(identifier)
(number))))))
================================================================================
casting
================================================================================
SELECT 1::text;
--------------------------------------------------------------------------------
(source_file
(select_statement
(select_item
(op_expression
(number)
(cast)
(identifier)))))
================================================================================
string concatenation
================================================================================
SELECT 'hello' || 1 || now();
--------------------------------------------------------------------------------
(source_file
(select_statement
(select_item
(op_expression
(op_expression
(string)
(other_op)
(number))
(other_op)
(function_call
(identifier))))))
================================================================================
string quote
================================================================================
SELECT 'hello' || 'quote''s everywh''ere';
--------------------------------------------------------------------------------
(source_file
(select_statement
(select_item
(op_expression
(string)
(other_op)
(string)))))
2021-08-31 21:29:46 +03:00
2021-09-01 20:14:42 +03:00
================================================================================
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)))))
2021-08-31 21:29:46 +03:00
================================================================================
is null, isnull, is not null, notnull
================================================================================
SELECT
foo is null,
foo is not null,
foo isnull,
foo notnull;
--------------------------------------------------------------------------------
(source_file
(select_statement
(select_item
(op_expression
(identifier)
(comparison_null)))
(select_item
(op_expression
(identifier)
(comparison_null)))
(select_item
(op_expression
(identifier)
(comparison_null)))
(select_item
(op_expression
(identifier)
(comparison_null)))))
2021-08-31 21:30:45 +03:00
================================================================================
time expressions
================================================================================
SELECT
foo::interval,
foo at time zone 'utc',
interval '1 day',
interval '1' hour to second,
interval '1' day + interval '3' month;
--------------------------------------------------------------------------------
(source_file
(select_statement
(select_item
(op_expression
(identifier)
(cast)
(identifier)))
(select_item
(time_expression
(identifier)
(string)))
(select_item
(time_expression
(string)))
(select_item
(time_expression
(string)))
(select_item
(op_expression
(time_expression
(string))
(time_expression
(string))))))