with cte can define columns
This commit is contained in:
parent
208d770137
commit
2aba292171
2 changed files with 51 additions and 1 deletions
|
@ -23,6 +23,33 @@ with w as (select * from foo) select * from w;
|
|||
(from_table
|
||||
(identifier))))))
|
||||
|
||||
================================================================================
|
||||
with column names
|
||||
================================================================================
|
||||
with w(foo, bar) as (select * from foo) select * from w;
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(select_statement
|
||||
(with_query
|
||||
(with_query_item
|
||||
(identifier)
|
||||
(identifier)
|
||||
(identifier)
|
||||
(select_statement
|
||||
(select_item
|
||||
(star))
|
||||
(select_from
|
||||
(from_item
|
||||
(from_table
|
||||
(identifier)))))))
|
||||
(select_item
|
||||
(star))
|
||||
(select_from
|
||||
(from_item
|
||||
(from_table
|
||||
(identifier))))))
|
||||
|
||||
================================================================================
|
||||
materialized
|
||||
================================================================================
|
||||
|
@ -110,6 +137,29 @@ with new as (insert into foo values(1)) select 1;
|
|||
(select_item
|
||||
(number))))
|
||||
|
||||
================================================================================
|
||||
with update
|
||||
================================================================================
|
||||
with new as (update foo set bar = 1 returning *) select 1;
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(select_statement
|
||||
(with_query
|
||||
(with_query_item
|
||||
(identifier)
|
||||
(update_statement
|
||||
(identifier)
|
||||
(update_set
|
||||
(identifier)
|
||||
(update_value
|
||||
(number)))
|
||||
(returning
|
||||
(select_item
|
||||
(star))))))
|
||||
(select_item
|
||||
(number))))
|
||||
|
||||
================================================================================
|
||||
many
|
||||
================================================================================
|
||||
|
|
|
@ -506,7 +506,7 @@ module.exports = grammar({
|
|||
with_query: $ => seq(kw("with"), commaSep1($.with_query_item)),
|
||||
with_query_item: $ => seq(
|
||||
$.identifier,
|
||||
// TODO(chrde): columns
|
||||
optional($._list_of_identifiers),
|
||||
kw("as"),
|
||||
optional(choice(kw("materialized"), seq(kw("not"), kw("materialized")))),
|
||||
"(", $._with_query_statement, ")"
|
||||
|
|
Loading…
Reference in a new issue