Skip to content
This repository was archived by the owner on Jul 15, 2021. It is now read-only.

Commit ad6c62e

Browse files
committed
Allow view expression in CREATE VIEW statement.
A view expression can now be used in a `CREATE VIEW` statement. ``` sql CREATE VIEW v1(a, b) AS VALUES(1, 2), (3, 4); ```
1 parent 8844885 commit ad6c62e

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,12 @@ All notable changes to this project will be documented in this file.
414414
SELECT * FROM s;
415415
```
416416

417+
- A view expression can now be used in a `CREATE VIEW` statement.
418+
419+
``` sql
420+
CREATE VIEW v1(a, b) AS VALUES(1, 2), (3, 4);
421+
```
422+
417423
## [v0.14.5] - 2016-07-11
418424
### Fixed
419425
- Fix alternate not equal operator `<>`

src/grammar.pegjs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2408,7 +2408,7 @@ action_loop_stmt
24082408
{ return s; }
24092409

24102410
create_view "CREATE VIEW Statement"
2411-
= s:( create_view_start ) ne:( create_core_ine )? n:( id_view ) o
2411+
= s:( create_view_start ) ne:( create_core_ine )? n:( id_view_expression ) o
24122412
r:( create_as_select )
24132413
{
24142414
return Object.assign({
@@ -2418,6 +2418,18 @@ create_view "CREATE VIEW Statement"
24182418
}, s, ne);
24192419
}
24202420

2421+
id_view_expression
2422+
= n:( id_view ) o a:( loop_columns ) {
2423+
return Object.assign({
2424+
'type': 'identifier',
2425+
'variant': 'expression',
2426+
'format': 'view',
2427+
'name': n['name'],
2428+
'columns': []
2429+
}, a);
2430+
}
2431+
/ id_view
2432+
24212433
create_view_start
24222434
= s:( create_start ) tmp:( create_core_tmp )? v:( VIEW ) o
24232435
{

0 commit comments

Comments
 (0)