Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ module.exports = grammar({
),

add_column: $ => seq(
$.keyword_add,
optional($.keyword_add),
optional(
$.keyword_column,
),
Expand All @@ -1143,7 +1143,7 @@ module.exports = grammar({

add_constraint: $ => seq(
$.keyword_add,
$.keyword_constraint,
optional($.keyword_constraint),
$.identifier,
$.constraint,
),
Expand Down
49 changes: 42 additions & 7 deletions test/corpus/alter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,6 @@ Alter table and multiple
ALTER TABLE IF EXISTS my_table
ADD COLUMN IF NOT EXISTS val4 DATE,
ALTER COLUMN val5 DROP NOT NULL, -- comment, ignore me!
RENAME COLUMN val6 TO val7,
DROP COLUMN IF EXISTS val8;

--------------------------------------------------------------------------------
Expand Down Expand Up @@ -456,12 +455,6 @@ ALTER TABLE IF EXISTS my_table
(keyword_not)
(keyword_null))
(comment)
(rename_column
(keyword_rename)
(keyword_column)
old_name: (identifier)
(keyword_to)
new_name: (identifier))
(drop_column
(keyword_drop)
(keyword_column)
Expand Down Expand Up @@ -626,3 +619,45 @@ new_table TO old_table;
(keyword_to)
(object_reference
(identifier))))

================================================================================
T-SQL: alter table add multiple columns at once
================================================================================

ALTER TABLE tab
ADD
col1 VARCHAR(255) NOT NULL DEFAULT('EMPTY'),
col2 VARCHAR(255) NOT NULL DEFAULT('EMPTY');

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

(program
(statement
(alter_table
(keyword_alter)
(keyword_table)
(object_reference
(identifier))
(add_column
(keyword_add)
(column_definition
(identifier)
(varchar
(keyword_varchar)
(literal))
(keyword_not)
(keyword_null)
(keyword_default)
(list
(literal))))
(add_column
(column_definition
(identifier)
(varchar
(keyword_varchar)
(literal))
(keyword_not)
(keyword_null)
(keyword_default)
(list
(literal)))))))