Repository: DerekStride/tree-sitter-sql (language: python)

Issue:
SQL file lose syntax
Hello, I have a problem with syntax highlighting in an SQL file. I created an issue in the nvim-treesitter repository, but I was advised to come here. I am attaching a screenshot of what it looks like in my nvim 9.
<img width="1489" alt="image" src="https://user-images.githubusercontent.com/48452376/232732596-1bae3deb-0dc0-4264-9b1c-4428d3cc3e78.png">
Also here is a link to the issue in nvim-treesiter repo - there is more information about my problem.
[https://github.com/nvim-treesitter/nvim-treesitter/issues/4668](https://github.com/nvim-treesitter/nvim-treesitter/issues/4668)
SQL file lose syntax
Hello, I have a problem with syntax highlighting in an SQL file. I created an issue in the nvim-treesitter repository, but I was advised to come here. I am attaching a screenshot of what it looks like in my nvim 9.
<img width="1489" alt="image" src="https://user-images.githubusercontent.com/48452376/232732596-1bae3deb-0dc0-4264-9b1c-4428d3cc3e78.png">
Also here is a link to the issue in nvim-treesiter repo - there is more information about my problem.
[https://github.com/nvim-treesitter/nvim-treesitter/issues/4668](https://github.com/nvim-treesitter/nvim-treesitter/issues/4668)


Discussion / hints:

Fix patch:
diff --git a/grammar.js b/grammar.js
index 6efa6503..0a285b96 100644
--- a/grammar.js
+++ b/grammar.js
@@ -107,6 +107,8 @@ module.exports = grammar({
     keyword_if: _ => make_keyword("if"),
     keyword_exists: _ => make_keyword("exists"),
     keyword_auto_increment: _ => make_keyword("auto_increment"),
+    keyword_generated: _ => make_keyword("generated"),
+    keyword_always: _ => make_keyword("always"),
     keyword_collate: _ => make_keyword("collate"),
     keyword_character: _ => make_keyword("character"),
     keyword_engine: _ => make_keyword("engine"),
@@ -155,6 +157,8 @@ module.exports = grammar({
     keyword_others: _ => make_keyword("others"),
     keyword_only: _ => make_keyword("only"),
     keyword_unique: _ => make_keyword("unique"),
+    keyword_foreign: _ => make_keyword("foreign"),
+    keyword_references: _ => make_keyword("references"),
     keyword_concurrently: _ => make_keyword("concurrently"),
     keyword_btree: _ => make_keyword("btree"),
     keyword_hash: _ => make_keyword("hash"),
@@ -257,6 +261,7 @@ module.exports = grammar({
     keyword_float: _ => make_keyword("float"),
     keyword_double: _ => make_keyword("double"),
     keyword_precision: _ => make_keyword("precision"),
+    keyword_inet: _ => make_keyword("inet"),
 
     keyword_money: _ => make_keyword("money"),
     keyword_varying: _ => make_keyword("varying"),
@@ -354,6 +359,7 @@ module.exports = grammar({
       $.keyword_xml,
 
       $.keyword_bytea,
+      $.keyword_inet,
 
       $.enum,
 
@@ -741,7 +747,7 @@ module.exports = grammar({
       optional(
         seq(
           optional($._if_not_exists),
-          $.identifier,
+          field("column", $._column),
         ),
       ),
       $.keyword_on,
@@ -795,6 +801,7 @@ module.exports = grammar({
 
     _alter_specifications: $ => choice(
       $.add_column,
+      $.add_constraint,
       $.alter_column,
       $.modify_column,
       $.change_column,
@@ -815,6 +822,13 @@ module.exports = grammar({
       optional($.column_position),
     ),
 
+    add_constraint: $ => seq(
+      $.keyword_add,
+      $.keyword_constraint,
+      $.field,
+      $.constraint,
+    ),
+
     alter_column: $ => seq(
       // TODO constraint management
       $.keyword_alter,
@@ -988,7 +1002,10 @@ module.exports = grammar({
           '.',
         ),
       ),
-      field('name', $.identifier),
+      choice(
+        field('name', $.identifier),
+        field('name', alias($._literal_string, $.identifier)),
+      ),
     ),
 
     _insert_statement: $ => seq(
@@ -1057,7 +1074,10 @@ module.exports = grammar({
     ),
 
     _column_list: $ => paren_list(alias($._column, $.column), true),
-    _column: $ => field('name', $.identifier),
+    _column: $ => choice(
+      $.identifier,
+      alias($._literal_string, $.literal),
+    ),
 
     _update_statement: $ => seq(
       $.update,
@@ -1231,7 +1251,7 @@ module.exports = grammar({
     ),
 
     column_definition: $ => seq(
-      field('name', $.identifier),
+      field('name', $._column),
       field('type', $._type),
       repeat($._column_constraint),
     ),
@@ -1251,6 +1271,11 @@ module.exports = grammar({
         $.keyword_auto_increment,
         $.direction,
         $._column_comment,
+        seq(
+          optional(seq($.keyword_generated, $.keyword_always)),
+          $.keyword_as,
+          $.identifier,
+        ),
     ),
 
     _default_expression: $ => seq(
@@ -1303,16 +1328,35 @@ module.exports = grammar({
     ),
 
     _key_constraint: $ => seq(
-      optional($.keyword_unique),
+      optional(
+        choice(
+          $.keyword_unique,
+          $.keyword_foreign,
+        ),
+      ),
       choice($.keyword_key, $.keyword_index),
-      field('name', $.identifier),
+      optional(field('name', $.identifier)),
       $.ordered_columns,
+      optional(
+        seq(
+          $.keyword_references,
+          $.table_reference,
+          $.ordered_columns,
+          optional(
+            seq(
+              $.keyword_on,
+              $.keyword_delete,
+              $.keyword_cascade,
+            ),
+          ),
+        ),
+      ),
     ),
 
     ordered_columns: $ => paren_list(alias($.ordered_column, $.column), true),
 
     ordered_column: $ => seq(
-      field('name', $.identifier),
+      field('name', $._column),
       optional($.direction),
     ),
 


Test patch:
diff --git a/test/corpus/alter.txt b/test/corpus/alter.txt
index a5bf7326..09001013 100644
--- a/test/corpus/alter.txt
+++ b/test/corpus/alter.txt
@@ -1,416 +1,426 @@
-==================
+================================================================================
 Alter table and add column
-==================
+================================================================================
 
 ALTER TABLE my_table
   ADD COLUMN val3 VARCHAR(100) NOT NULL;
 
----
+--------------------------------------------------------------------------------
 
 (program
- (statement
-  (alter_table
-   (keyword_alter)
-   (keyword_table)
-   (table_reference name: (identifier))
-   (add_column
-    (keyword_add)
-    (keyword_column)
-    (column_definition
-     name: (identifier)
-     type: (varchar
-      (keyword_varchar)
-      size: (literal))
-     (keyword_not)
-     (keyword_null))
-   ))))
-
-==================
+  (statement
+    (alter_table
+      (keyword_alter)
+      (keyword_table)
+      (table_reference
+        name: (identifier))
+      (add_column
+        (keyword_add)
+        (keyword_column)
+        (column_definition
+          name: (identifier)
+          type: (varchar
+            (keyword_varchar)
+            size: (literal))
+          (keyword_not)
+          (keyword_null))))))
+
+================================================================================
 Alter table and add column, eliding column keyword
-==================
+================================================================================
 
 ALTER TABLE my_table
   ADD val3 VARCHAR(100) NOT NULL;
 
----
+--------------------------------------------------------------------------------
 
 (program
- (statement
-  (alter_table
-   (keyword_alter)
-   (keyword_table)
-   (table_reference name: (identifier))
-   (add_column
-    (keyword_add)
-    (column_definition
-     name: (identifier)
-     type: (varchar
-      (keyword_varchar)
-      size: (literal))
-     (keyword_not)
-     (keyword_null))
-   ))))
-
-==================
+  (statement
+    (alter_table
+      (keyword_alter)
+      (keyword_table)
+      (table_reference
+        name: (identifier))
+      (add_column
+        (keyword_add)
+        (column_definition
+          name: (identifier)
+          type: (varchar
+            (keyword_varchar)
+            size: (literal))
+          (keyword_not)
+          (keyword_null))))))
+
+================================================================================
 Alter table and add column first
-==================
+================================================================================
 
 ALTER TABLE my_table
   ADD val3 VARCHAR(100) NOT NULL FIRST;
 
----
+--------------------------------------------------------------------------------
 
 (program
- (statement
-  (alter_table
-   (keyword_alter)
-   (keyword_table)
-   (table_reference name: (identifier))
-   (add_column
-    (keyword_add)
-    (column_definition
-     name: (identifier)
-     type: (varchar
-      (keyword_varchar)
-      size: (literal))
-     (keyword_not)
-     (keyword_null))
-    (column_position
-     (keyword_first))))))
-
-==================
+  (statement
+    (alter_table
+      (keyword_alter)
+      (keyword_table)
+      (table_reference
+        name: (identifier))
+      (add_column
+        (keyword_add)
+        (column_definition
+          name: (identifier)
+          type: (varchar
+            (keyword_varchar)
+            size: (literal))
+          (keyword_not)
+          (keyword_null))
+        (column_position
+          (keyword_first))))))
+
+================================================================================
 Alter table and add column after column
-==================
+================================================================================
 
 ALTER TABLE my_table
   ADD val3 VARCHAR(100) NOT NULL AFTER val2;
 
----
+--------------------------------------------------------------------------------
 
 (program
- (statement
-  (alter_table
-   (keyword_alter)
-   (keyword_table)
-   (table_reference name: (identifier))
-   (add_column
-    (keyword_add)
-    (column_definition
-     name: (identifier)
-     type: (varchar
-      (keyword_varchar)
-      size: (literal))
-     (keyword_not)
-     (keyword_null))
-    (column_position
-     (keyword_after)
-     col_name: (identifier))))))
-
-==================
+  (statement
+    (alter_table
+      (keyword_alter)
+      (keyword_table)
+      (table_reference
+        name: (identifier))
+      (add_column
+        (keyword_add)
+        (column_definition
+          name: (identifier)
+          type: (varchar
+            (keyword_varchar)
+            size: (literal))
+          (keyword_not)
+          (keyword_null))
+        (column_position
+          (keyword_after)
+          col_name: (identifier))))))
+
+================================================================================
 Alter table and alter column setting default
-==================
+================================================================================
 
 ALTER TABLE my_table
   ALTER COLUMN val3 SET DEFAULT 'hi';
 
----
+--------------------------------------------------------------------------------
 
 (program
- (statement
-  (alter_table
-   (keyword_alter)
-   (keyword_table)
-   (table_reference name: (identifier))
-   (alter_column
-    (keyword_alter)
-    (keyword_column)
-    name: (identifier)
-    (keyword_set)
-    (keyword_default)
-    (literal)
-  ))))
-
-==================
+  (statement
+    (alter_table
+      (keyword_alter)
+      (keyword_table)
+      (table_reference
+        name: (identifier))
+      (alter_column
+        (keyword_alter)
+        (keyword_column)
+        name: (identifier)
+        (keyword_set)
+        (keyword_default)
+        (literal)))))
+
+================================================================================
 Alter table and alter column dropping default
-==================
+================================================================================
 
 ALTER TABLE my_table
   ALTER COLUMN val3 DROP DEFAULT;
 
----
+--------------------------------------------------------------------------------
 
 (program
- (statement
-  (alter_table
-   (keyword_alter)
-   (keyword_table)
-   (table_reference name: (identifier))
-   (alter_column
-    (keyword_alter)
-    (keyword_column)
-    name: (identifier)
-    (keyword_drop)
-    (keyword_default)
-  ))))
-
-==================
+  (statement
+    (alter_table
+      (keyword_alter)
+      (keyword_table)
+      (table_reference
+        name: (identifier))
+      (alter_column
+        (keyword_alter)
+        (keyword_column)
+        name: (identifier)
+        (keyword_drop)
+        (keyword_default)))))
+
+================================================================================
 Alter table and alter column changing type
-==================
+================================================================================
 
 ALTER TABLE my_table
   ALTER COLUMN val3 TYPE VARCHAR(255);
 
----
+--------------------------------------------------------------------------------
 
 (program
- (statement
-  (alter_table
-   (keyword_alter)
-   (keyword_table)
-   (table_reference name: (identifier))
-   (alter_column
-    (keyword_alter)
-    (keyword_column)
-    name: (identifier)
-    (keyword_type)
-    type: (varchar (keyword_varchar) size: (literal)))
-  )))
-
-==================
+  (statement
+    (alter_table
+      (keyword_alter)
+      (keyword_table)
+      (table_reference
+        name: (identifier))
+      (alter_column
+        (keyword_alter)
+        (keyword_column)
+        name: (identifier)
+        (keyword_type)
+        type: (varchar
+          (keyword_varchar)
+          size: (literal))))))
+
+================================================================================
 Alter table and modify column changing type and position
-==================
+================================================================================
 
 ALTER TABLE my_table
   MODIFY COLUMN IF EXISTS val6 INT UNSIGNED NOT NULL AFTER val3;
 
----
+--------------------------------------------------------------------------------
 
 (program
- (statement
-  (alter_table
-   (keyword_alter)
-   (keyword_table)
-   (table_reference
-    name: (identifier))
-   (modify_column
-    (keyword_modify)
-    (keyword_column)
-    (keyword_if)
-    (keyword_exists)
-    (column_definition
-     name: (identifier)
-     type: (int 
-      (keyword_int)
-      (keyword_unsigned))
-     (keyword_not)
-     (keyword_null))
-    (column_position
-     (keyword_after)
-     col_name: (identifier))))))
-
-==================
+  (statement
+    (alter_table
+      (keyword_alter)
+      (keyword_table)
+      (table_reference
+        name: (identifier))
+      (modify_column
+        (keyword_modify)
+        (keyword_column)
+        (keyword_if)
+        (keyword_exists)
+        (column_definition
+          name: (identifier)
+          type: (int
+            (keyword_int)
+            (keyword_unsigned))
+          (keyword_not)
+          (keyword_null))
+        (column_position
+          (keyword_after)
+          col_name: (identifier))))))
+
+================================================================================
 Alter table and change column renaming and changing type
-==================
+================================================================================
 
 ALTER TABLE my_table
   CHANGE COLUMN IF EXISTS val3 val4 INT UNSIGNED NOT NULL;
 
----
+--------------------------------------------------------------------------------
 
 (program
- (statement
-  (alter_table
-   (keyword_alter)
-   (keyword_table)
-   (table_reference name: (identifier))
-   (change_column
-    (keyword_change)
-    (keyword_column)
-    (keyword_if)
-    (keyword_exists)
-    old_name: (identifier)
-    (column_definition
-     name: (identifier)
-     type: (int 
-      (keyword_int)
-      (keyword_unsigned))
-     (keyword_not)
-     (keyword_null))))))
-
-==================
+  (statement
+    (alter_table
+      (keyword_alter)
+      (keyword_table)
+      (table_reference
+        name: (identifier))
+      (change_column
+        (keyword_change)
+        (keyword_column)
+        (keyword_if)
+        (keyword_exists)
+        old_name: (identifier)
+        (column_definition
+          name: (identifier)
+          type: (int
+            (keyword_int)
+            (keyword_unsigned))
+          (keyword_not)
+          (keyword_null))))))
+
+================================================================================
 Alter table and alter column changing type, eliding column keyword
-==================
+================================================================================
 
 ALTER TABLE my_table
   ALTER val3 TYPE VARCHAR(255);
 
----
+--------------------------------------------------------------------------------
 
 (program
- (statement
-  (alter_table
-   (keyword_alter)
-   (keyword_table)
-   (table_reference name: (identifier))
-   (alter_column
-    (keyword_alter)
-    name: (identifier)
-    (keyword_type)
-    type: (varchar (keyword_varchar) size: (literal)))
-  )))
-
-==================
+  (statement
+    (alter_table
+      (keyword_alter)
+      (keyword_table)
+      (table_reference
+        name: (identifier))
+      (alter_column
+        (keyword_alter)
+        name: (identifier)
+        (keyword_type)
+        type: (varchar
+          (keyword_varchar)
+          size: (literal))))))
+
+================================================================================
 Alter table and alter column dropping not-null constraint
-==================
+================================================================================
 
 ALTER TABLE my_table
   ALTER COLUMN val3 DROP NOT NULL;
 
----
+--------------------------------------------------------------------------------
 
 (program
- (statement
-  (alter_table
-   (keyword_alter)
-   (keyword_table)
-   (table_reference name: (identifier))
-   (alter_column
-    (keyword_alter)
-    (keyword_column)
-    name: (identifier)
-    (keyword_drop)
-    (keyword_not)
-    (keyword_null)))))
-
-==================
+  (statement
+    (alter_table
+      (keyword_alter)
+      (keyword_table)
+      (table_reference
+        name: (identifier))
+      (alter_column
+        (keyword_alter)
+        (keyword_column)
+        name: (identifier)
+        (keyword_drop)
+        (keyword_not)
+        (keyword_null)))))
+
+================================================================================
 Alter table and drop column
-==================
+================================================================================
 
 ALTER TABLE my_table
   DROP COLUMN val3;
 
----
+--------------------------------------------------------------------------------
 
 (program
- (statement
-  (alter_table
-   (keyword_alter)
-   (keyword_table)
-   (table_reference name: (identifier))
-   (drop_column
-    (keyword_drop)
-    (keyword_column)
-    name: (identifier))
-  )))
-
-==================
+  (statement
+    (alter_table
+      (keyword_alter)
+      (keyword_table)
+      (table_reference
+        name: (identifier))
+      (drop_column
+        (keyword_drop)
+        (keyword_column)
+        name: (identifier)))))
+
+================================================================================
 Alter table and drop column, eliding column keyword
-==================
+================================================================================
 
 ALTER TABLE my_table
   DROP val3;
 
----
+--------------------------------------------------------------------------------
 
 (program
- (statement
-  (alter_table
-   (keyword_alter)
-   (keyword_table)
-   (table_reference name: (identifier))
-   (drop_column
-    (keyword_drop)
-    name: (identifier))
-  )))
-
-==================
+  (statement
+    (alter_table
+      (keyword_alter)
+      (keyword_table)
+      (table_reference
+        name: (identifier))
+      (drop_column
+        (keyword_drop)
+        name: (identifier)))))
+
+================================================================================
 Alter table and rename column
-==================
+================================================================================
 
 ALTER TABLE my_table
   RENAME COLUMN val3 TO valthree;
 
----
+--------------------------------------------------------------------------------
 
 (program
- (statement
-  (alter_table
-   (keyword_alter)
-   (keyword_table)
-   (table_reference name: (identifier))
-   (rename_column
-    (keyword_rename)
-    (keyword_column)
-    old_name: (identifier)
-    (keyword_to)
-    new_name: (identifier)))))
-
-==================
+  (statement
+    (alter_table
+      (keyword_alter)
+      (keyword_table)
+      (table_reference
+        name: (identifier))
+      (rename_column
+        (keyword_rename)
+        (keyword_column)
+        old_name: (identifier)
+        (keyword_to)
+        new_name: (identifier)))))
+
+================================================================================
 Alter and rename table
-==================
+================================================================================
 
 ALTER TABLE my_table
   RENAME TO my_new_and_improved_table;
 
----
+--------------------------------------------------------------------------------
 
 (program
- (statement
-  (alter_table
-   (keyword_alter)
-   (keyword_table)
-   (table_reference name: (identifier))
-   (rename_object
-    (keyword_rename)
-    (keyword_to)
-    (table_reference name: (identifier))
-   ))))
-
-==================
+  (statement
+    (alter_table
+      (keyword_alter)
+      (keyword_table)
+      (table_reference
+        name: (identifier))
+      (rename_object
+        (keyword_rename)
+        (keyword_to)
+        (table_reference
+          name: (identifier))))))
+
+================================================================================
 Alter table and set schema
-==================
+================================================================================
 
 ALTER TABLE my_table
   SET SCHEMA new_schema;
 
----
+--------------------------------------------------------------------------------
 
 (program
- (statement
-  (alter_table
-   (keyword_alter)
-   (keyword_table)
-   (table_reference name: (identifier))
-   (set_schema
-    (keyword_set)
-    (keyword_schema)
-    schema: (identifier)
-   ))))
-
-==================
+  (statement
+    (alter_table
+      (keyword_alter)
+      (keyword_table)
+      (table_reference
+        name: (identifier))
+      (set_schema
+        (keyword_set)
+        (keyword_schema)
+        schema: (identifier)))))
+
+================================================================================
 Alter table and change owner
-==================
+================================================================================
 
 ALTER TABLE my_table
   OWNER TO someone_else;
 
----
+--------------------------------------------------------------------------------
 
 (program
- (statement
-  (alter_table
-   (keyword_alter)
-   (keyword_table)
-   (table_reference name: (identifier))
-   (change_ownership
-    (keyword_owner)
-    (keyword_to)
-    (identifier)
-   ))))
-
-==================
+  (statement
+    (alter_table
+      (keyword_alter)
+      (keyword_table)
+      (table_reference
+        name: (identifier))
+      (change_ownership
+        (keyword_owner)
+        (keyword_to)
+        (identifier)))))
+
+================================================================================
 Alter table and multiple
-==================
+================================================================================
 
 ALTER TABLE IF EXISTS my_table
   ADD COLUMN IF NOT EXISTS val4 DATE,
@@ -418,85 +428,174 @@ ALTER TABLE IF EXISTS my_table
   RENAME COLUMN val6 TO val7,
   DROP COLUMN IF EXISTS val8;
 
----
+--------------------------------------------------------------------------------
 
 (program
- (statement
-  (alter_table
-   (keyword_alter)
-   (keyword_table)
-   (keyword_if)
-   (keyword_exists)
-   (table_reference name: (identifier))
-   (add_column
-    (keyword_add)
-    (keyword_column)
-    (keyword_if)
-    (keyword_not)
-    (keyword_exists)
-    (column_definition name: (identifier) type: (keyword_date)))
-   (alter_column
-    (keyword_alter)
-    (keyword_column)
-    name: (identifier)
-    (keyword_drop)
-    (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)
-    (keyword_if)
-    (keyword_exists)
-    name: (identifier))
-  )))
-
-==================
+  (statement
+    (alter_table
+      (keyword_alter)
+      (keyword_table)
+      (keyword_if)
+      (keyword_exists)
+      (table_reference
+        name: (identifier))
+      (add_column
+        (keyword_add)
+        (keyword_column)
+        (keyword_if)
+        (keyword_not)
+        (keyword_exists)
+        (column_definition
+          name: (identifier)
+          type: (keyword_date)))
+      (alter_column
+        (keyword_alter)
+        (keyword_column)
+        name: (identifier)
+        (keyword_drop)
+        (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)
+        (keyword_if)
+        (keyword_exists)
+        name: (identifier)))))
+
+================================================================================
 Alter view and change owner
-==================
+================================================================================
 
 ALTER VIEW my_view
   OWNER TO someone_else;
 
----
+--------------------------------------------------------------------------------
 
 (program
- (statement
-  (alter_view
-   (keyword_alter)
-   (keyword_view)
-   (table_reference name: (identifier))
-   (change_ownership
-    (keyword_owner)
-    (keyword_to)
-    (identifier)
-   ))))
-
-==================
+  (statement
+    (alter_view
+      (keyword_alter)
+      (keyword_view)
+      (table_reference
+        name: (identifier))
+      (change_ownership
+        (keyword_owner)
+        (keyword_to)
+        (identifier)))))
+
+================================================================================
 Alter view and rename
-==================
+================================================================================
 
 ALTER VIEW IF EXISTS my_view
   RENAME TO my_other_view;
 
----
+--------------------------------------------------------------------------------
 
 (program
- (statement
-  (alter_view
-   (keyword_alter)
-   (keyword_view)
-   (keyword_if)
-   (keyword_exists)
-   (table_reference name: (identifier))
-   (rename_object
-    (keyword_rename)
-    (keyword_to)
-    (table_reference name: (identifier))
-   ))))
+  (statement
+    (alter_view
+      (keyword_alter)
+      (keyword_view)
+      (keyword_if)
+      (keyword_exists)
+      (table_reference
+        name: (identifier))
+      (rename_object
+        (keyword_rename)
+        (keyword_to)
+        (table_reference
+          name: (identifier))))))
+
+================================================================================
+alter with constraint
+================================================================================
+
+ALTER TABLE "Role" ADD CONSTRAINT "pkRole" PRIMARY KEY ("roleId");
+
+--------------------------------------------------------------------------------
+
+(program
+  (statement
+    (alter_table
+      (keyword_alter)
+      (keyword_table)
+      (table_reference
+        name: (identifier))
+      (add_constraint
+        (keyword_add)
+        (keyword_constraint)
+        (field
+          name: (identifier))
+        (constraint
+          (keyword_primary)
+          (keyword_key)
+          (ordered_columns
+            (column
+              name: (literal))))))))
+
+================================================================================
+CREATE UNIQUE INDEX
+================================================================================
+
+CREATE UNIQUE INDEX "akRoleName" ON "Role" ("name");
+
+--------------------------------------------------------------------------------
+
+(program
+  (statement
+    (create_index
+      (keyword_create)
+      (keyword_unique)
+      (keyword_index)
+      (literal)
+      (keyword_on)
+      (table_reference
+        (identifier))
+      (ordered_columns
+        (column
+          (literal))))))
+
+================================================================================
+Add foreign key constraint
+================================================================================
+
+ALTER TABLE "AccountRole" ADD CONSTRAINT "fkAccountRoleAccount"
+FOREIGN KEY ("accountId") REFERENCES "Account" ("accountId") ON DELETE CASCADE;
+
+--------------------------------------------------------------------------------
+
+(program
+  (statement
+    (alter_table
+      (keyword_alter)
+      (keyword_table)
+      (table_reference
+        name: (identifier))
+      (add_constraint
+        (keyword_add)
+        (keyword_constraint)
+        (field
+          name: (identifier))
+        (constraint
+          (keyword_foreign)
+          (keyword_key)
+          (ordered_columns
+            (column
+              name: (literal)))
+          (keyword_references)
+          (table_reference
+            name: (identifier))
+          (ordered_columns
+            (column
+              name: (literal)))
+          (keyword_on)
+          (keyword_delete)
+          (keyword_cascade))))))
diff --git a/test/corpus/create.txt b/test/corpus/create.txt
index f56e6f7c..345aeab2 100644
--- a/test/corpus/create.txt
+++ b/test/corpus/create.txt
@@ -957,11 +957,11 @@ CREATE TABLE type_test (
           type: (keyword_bytea))
         (column_definition
           name: (identifier)
-          type: (enum 
-                  (keyword_enum)
-                  value: (literal)
-                  value: (literal)
-                  value: (literal)))
+          type: (enum
+            (keyword_enum)
+            value: (literal)
+            value: (literal)
+            value: (literal)))
         (column_definition
           name: (identifier)
           type: (keyword_date))
@@ -1357,3 +1357,86 @@ CACHED IN 'pool1' WITH REPLICATION = 2
         (keyword_with)
         (keyword_replication)
         value: (literal)))))
+
+================================================================================
+Create table with string name
+================================================================================
+
+CREATE TABLE "Role" (
+    id BIGINT NOT NULL
+);
+
+--------------------------------------------------------------------------------
+
+(program
+  (statement
+    (create_table
+      (keyword_create)
+      (keyword_table)
+      (table_reference
+        name: (identifier))
+      (column_definitions
+        (column_definition
+          name: (identifier)
+          type: (bigint
+            (keyword_bigint))
+          (keyword_not)
+          (keyword_null))))))
+
+================================================================================
+Create table with generated always
+================================================================================
+
+CREATE TABLE "Role" (
+  "roleId" bigint generated always as identity,
+  "name" varchar NOT NULL
+);
+
+--------------------------------------------------------------------------------
+
+(program
+  (statement
+    (create_table
+      (keyword_create)
+      (keyword_table)
+      (table_reference
+        name: (identifier))
+      (column_definitions
+        (column_definition
+          name: (literal)
+          type: (bigint
+            (keyword_bigint))
+          (keyword_generated)
+          (keyword_always)
+          (keyword_as)
+          (identifier))
+        (column_definition
+          name: (literal)
+          type: (varchar
+            (keyword_varchar))
+          (keyword_not)
+          (keyword_null))))))
+
+================================================================================
+Inet type
+================================================================================
+
+CREATE TABLE "Session" (
+  "ip" inet NOT NULL
+);
+
+--------------------------------------------------------------------------------
+
+(program
+  (statement
+    (create_table
+      (keyword_create)
+      (keyword_table)
+      (table_reference
+        name: (identifier))
+      (column_definitions
+        (column_definition
+          name: (literal)
+          type: (keyword_inet)
+          (keyword_not)
+          (keyword_null))))))
diff --git a/test/corpus/cte.txt b/test/corpus/cte.txt
index a2e9fac8..3af89cc6 100644
--- a/test/corpus/cte.txt
+++ b/test/corpus/cte.txt
@@ -73,9 +73,9 @@ FROM second;
             name: (identifier))
           (list
             (column
-              name: (identifier))
+              (identifier))
             (column
-              name: (identifier)))
+              (identifier)))
           (keyword_values)
           (list
             (literal)
diff --git a/test/corpus/insert.txt b/test/corpus/insert.txt
index 461b2a7b..f8abbeee 100644
--- a/test/corpus/insert.txt
+++ b/test/corpus/insert.txt
@@ -37,7 +37,7 @@ VALUES('foo','bar', 3);
       (table_reference
         name: (identifier))
       (keyword_as)
-       table_alias: (identifier)
+      table_alias: (identifier)
       (keyword_values)
       (list
         (literal)
@@ -62,11 +62,11 @@ VALUES ('foo', 123, '2020');
         name: (identifier))
       (list
         (column
-          name: (identifier))
+          (identifier))
         (column
-          name: (identifier))
+          (identifier))
         (column
-          name: (identifier)))
+          (identifier)))
       (keyword_values)
       (list
         (literal)
@@ -92,11 +92,11 @@ FROM my_other_table;
         name: (identifier))
       (list
         (column
-          name: (identifier))
+          (identifier))
         (column
-          name: (identifier))
+          (identifier))
         (column
-          name: (identifier)))
+          (identifier)))
       (select
         (keyword_select)
         (select_expression
@@ -404,4 +404,3 @@ VALUES('foo','bar', 3);
         (literal)
         (literal)
         (literal)))))
-
diff --git a/test/corpus/select.txt b/test/corpus/select.txt
index 1fa72f0b..a5f11d2a 100644
--- a/test/corpus/select.txt
+++ b/test/corpus/select.txt
@@ -994,9 +994,9 @@ JOIN my_other_table b USING (q, w);
         (keyword_using)
         (list
           (column
-            name: (identifier))
+            (identifier))
           (column
-            name: (identifier)))))))
+            (identifier)))))))
 
 ================================================================================
 Join a VALUES clause
@@ -1034,9 +1034,9 @@ JOIN (VALUES (1, 2), (3, 4)) AS v (col1, col2) ON TRUE;
           table_alias: (identifier)
           (list
             (column
-              name: (identifier))
+              (identifier))
             (column
-              name: (identifier))))
+              (identifier))))
         (keyword_on)
         predicate: (literal
           (keyword_true))))))