tree-sitter-plpgsql/test/corpus/insert_statement/insert.txt

289 lines
7.3 KiB
Text
Raw Normal View History

2021-08-28 13:46:32 +03:00
================================================================================
basic
================================================================================
insert into my_table values (1);
2021-08-28 13:46:32 +03:00
--------------------------------------------------------------------------------
(source_file
(insert_statement
(identifier)
(insert_items
(insert_values
(insert_item (number))
)
)
)
)
2021-08-28 13:46:32 +03:00
================================================================================
insert into table by specified columns
================================================================================
insert into my_table (name, email, display_name) values
('foo', 'bar@biz.baz', 'Foo bar');
--------------------------------------------------------------------------------
(source_file
(insert_statement
(identifier)
(columns
(identifier)
(identifier)
(identifier)
)
(insert_items
(insert_values
(insert_item (string))
(insert_item (string))
(insert_item (string))
)
)
)
)
================================================================================
insert into table by specified columns with many values
================================================================================
insert into my_table (name, email, display_name) values
('foo', 'bar@biz.baz', 'Foo bar'),
('foo', 'bar@biz.baz', 'Foo bar'),
('foo', 'bar@biz.baz', 'Foo bar');
--------------------------------------------------------------------------------
(source_file
(insert_statement
(identifier)
(columns
(identifier)
(identifier)
(identifier)
)
(insert_items
(insert_values
(insert_item (string))
(insert_item (string))
(insert_item (string))
)
(insert_values
(insert_item (string))
(insert_item (string))
(insert_item (string))
)
(insert_values
(insert_item (string))
(insert_item (string))
(insert_item (string))
)
)
)
)
================================================================================
insert into table with alias
2021-08-28 13:46:32 +03:00
================================================================================
insert into foo.my_table as alias values(1);
--------------------------------------------------------------------------------
(source_file
(insert_statement
(identifier)
(as (identifier))
2021-08-28 13:46:32 +03:00
(insert_items
(insert_values
(insert_item (number))
)
)
)
)
2021-08-28 13:46:32 +03:00
================================================================================
insert into default values
2021-08-28 13:46:32 +03:00
================================================================================
insert into foo.my_table default values;
--------------------------------------------------------------------------------
(source_file
(insert_statement
(identifier)
(insert_items)
)
)
2021-08-28 13:46:32 +03:00
================================================================================
insert into with many value items
2021-08-28 13:46:32 +03:00
================================================================================
insert into foo.my_table values (1, 2);
2021-08-28 13:46:32 +03:00
--------------------------------------------------------------------------------
(source_file
(insert_statement
(identifier)
(insert_items
(insert_values
(insert_item (number))
(insert_item (number))
)
)
)
)
2021-08-28 13:46:32 +03:00
================================================================================
insert into with different kind of value items
2021-08-28 13:46:32 +03:00
================================================================================
insert into foo.my_table values (1, DEFAULT, (select 1, 2));
2021-08-28 13:46:32 +03:00
--------------------------------------------------------------------------------
(source_file
(insert_statement
(identifier)
(insert_items
(insert_values
(insert_item (number))
(insert_item)
(insert_item
(select_statement
(select_item (number))
(select_item (number))
)
)
)
)
)
)
2021-08-28 13:46:32 +03:00
================================================================================
insert into from select
2021-08-28 13:46:32 +03:00
================================================================================
insert into foo.my_table select column1 from foo bar;
--------------------------------------------------------------------------------
2021-09-02 21:45:02 +03:00
(source_file
(insert_statement
(identifier)
(insert_items
(select_statement
(select_item (identifier))
2021-09-02 21:45:02 +03:00
(select_from
(from_item
(from_table
(identifier)
(identifier)
)
)
)
)
)
)
)
2021-09-02 21:45:02 +03:00
================================================================================
insert into a table with the select enclosed in parentheses
2021-09-02 21:45:02 +03:00
================================================================================
insert into foo.my_table (select column1 from foo bar);
--------------------------------------------------------------------------------
2021-08-28 13:46:32 +03:00
(source_file
(insert_statement
(identifier)
(insert_items
(select_statement
(select_item (identifier))
2021-08-28 13:46:32 +03:00
(select_from
(from_item
(from_table
(identifier)
(identifier)
)
)
)
)
)
)
)
2021-08-28 13:46:32 +03:00
================================================================================
insert into with returning clause
2021-08-28 13:46:32 +03:00
================================================================================
insert into foo values (1) returning *, 1;
2021-08-28 13:46:32 +03:00
--------------------------------------------------------------------------------
(source_file
(insert_statement
(identifier)
(insert_items
(insert_values
(insert_item (number))
)
)
2021-09-01 20:15:10 +03:00
(returning
(select_item (star))
(select_item (number))
)
)
)
2021-08-28 13:46:32 +03:00
================================================================================
insert into using with clause
2021-08-28 13:46:32 +03:00
================================================================================
with foo as (select * from bar)
insert into my_table values (1);
2021-08-28 13:46:32 +03:00
--------------------------------------------------------------------------------
(source_file
(insert_statement
(with_query
(with_query_item
(identifier)
(select_statement
(select_item (star))
2021-08-28 13:46:32 +03:00
(select_from
(from_item
(from_table
(identifier)
)
)
)
)
)
)
2021-08-28 13:46:32 +03:00
(identifier)
(insert_items
(insert_values
(insert_item (number))
)
)
)
)
2021-08-28 13:46:32 +03:00
================================================================================
insert into statement with returning into clause
2021-08-28 13:46:32 +03:00
================================================================================
insert into foo (bar, baz) select * from another
2021-08-28 13:46:32 +03:00
returning id into _var;
--------------------------------------------------------------------------------
(source_file
(insert_statement
(identifier)
(columns
(identifier)
(identifier)
)
2021-08-28 13:46:32 +03:00
(insert_items
(select_statement
(select_item (star))
2021-08-28 13:46:32 +03:00
(select_from
(from_item
(from_table
(identifier)
)
)
)
)
)
2021-09-01 20:15:10 +03:00
(returning
(select_item (identifier))
)
(into (identifier))
)
)