tree-sitter-plpgsql/corpus/select_statement/value_expression.txt
2021-09-02 19:54:27 +02:00

352 lines
9.3 KiB
Text

================================================================================
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
(number))
(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))))
================================================================================
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)))))
================================================================================
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
(number)
(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)))))
================================================================================
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
================================================================================
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)))))
================================================================================
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))))))