Skip to main content

Module create_table

Module create_table 

Source
Expand description

CREATE TABLE sub-phase analyzer.

When the cursor sits inside the parenthesised body of a CREATE TABLE statement we want much narrower completion than the general SQL state machine offers: types when writing a column type, column constraint keywords (NOT NULL / DEFAULT / …) after the type, tables after REFERENCES, and so on. The user explicitly does NOT want all-table-column completion when they are typing a column identifier.

Strategy:

  1. Locate every CREATE TABLE [IF NOT EXISTS] <name> ( whose body contains the cursor.
  2. From the body-open paren up to the cursor, tokenize and walk an entry-level state machine that resets on each top-level ,.
  3. Return a Phase reflecting what the user is about to type.

Functions§

detect
Try to classify the cursor’s position inside an enclosing CREATE TABLE body. Returns None when the cursor is not inside one.