Skip to content

Commit

Permalink
feat: Add set operation (select ... union select ...) for insert stat…
Browse files Browse the repository at this point in the history
…ements.
  • Loading branch information
antoineB committed Oct 8, 2023
1 parent 385aff4 commit 970b548
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1907,7 +1907,7 @@ module.exports = grammar({
$.keyword_values,
comma_list($.list, true),
),
$._select_statement,
$._dml_read,
),
),

Expand Down
35 changes: 35 additions & 0 deletions test/corpus/insert.txt
Original file line number Diff line number Diff line change
Expand Up @@ -526,3 +526,38 @@ FROM
(identifier))
(literal)))))
(identifier))))))

================================================================================
Insert from unioned select
================================================================================

INSERT INTO some_table
(field)
(SELECT "String value"
UNION
SELECT "String value");

--------------------------------------------------------------------------------

(program
(statement
(insert
(keyword_insert)
(keyword_into)
(object_reference
(identifier))
(list
(column
(identifier)))
(set_operation
(select
(keyword_select)
(select_expression
(term
(literal))))
(keyword_union)
(select
(keyword_select)
(select_expression
(term
(literal))))))))

0 comments on commit 970b548

Please sign in to comment.