Advanced-mode create table T ( suggests table-level constraints before suggesting a column name #4

Closed
opened 2026-05-28 14:43:51 +01:00 by oliversturm · 1 comment
oliversturm commented 2026-05-28 14:43:51 +01:00 (Migrated from github.com)

Observed

After create table Orders (, the completion hints suggest:
primary, unique, check, constraint, foreign

…before any hint for a column name. The dominant case at this position is "now type a column name"; table-level constraints are the rarer follow-up.

Why

ELEMENT_CHOICES in src/dsl/grammar/sql_create_table.rs:391 lists the choices in this order:

TABLE_PK, TABLE_UNIQUE, TABLE_CHECK, TABLE_FK_NAMED, TABLE_FK, COLUMN_DEF

The first five start with reserved keywords and so surface as concrete literal candidates; COLUMN_DEF starts with COL_NAME (an Ident / NewName role) — a less concrete "type something" hint — so it ranks last in the displayed list.

Expected

A column name (the COLUMN_DEF first move) should be the prominent suggestion. Table-level constraints can still appear, but they shouldn't crowd out the most common next step. Possible fixes: reorder the choices, weight ident roles higher in hint rendering, or split into "column name (most common)" vs "or constraint:" groupings.

### Observed After `create table Orders (`, the completion hints suggest: `primary`, `unique`, `check`, `constraint`, `foreign` …before any hint for a column name. The dominant case at this position is *"now type a column name"*; table-level constraints are the rarer follow-up. ### Why `ELEMENT_CHOICES` in `src/dsl/grammar/sql_create_table.rs:391` lists the choices in this order: ``` TABLE_PK, TABLE_UNIQUE, TABLE_CHECK, TABLE_FK_NAMED, TABLE_FK, COLUMN_DEF ``` The first five start with reserved keywords and so surface as concrete literal candidates; `COLUMN_DEF` starts with `COL_NAME` (an `Ident` / `NewName` role) — a less concrete "type something" hint — so it ranks last in the displayed list. ### Expected A column name (the `COLUMN_DEF` first move) should be the prominent suggestion. Table-level constraints can still appear, but they shouldn't crowd out the most common next step. Possible fixes: reorder the choices, weight ident roles higher in hint rendering, or split into "column name (most common)" vs "or constraint:" groupings.
oliversturm commented 2026-05-28 20:01:34 +01:00 (Migrated from github.com)

Resolved in commit 6f87ad1.

Added a new HintMode::IntroProse(&'static str) variant that surfaces catalog prose at slot entry without suppressing Tab completion (unlike ProseOnly) and without requiring typing_name_at_cursor to fire (unlike ForceProse). Wrapped ELEMENT in Node::Hinted { mode: IntroProse("hint.create_table_element"), … }.

At create table T ( the ambient hint now reads: "Type a column name, or a table-level constraint: primary, unique, check, constraint, foreign" — column name is the dominant first move; the constraint alternatives are folded into the prose. Tab still cycles every keyword.

The new variant is an additive extension to the ADR-0024 HintMode-per-node model; no behaviour change to existing modes.

Resolved in commit 6f87ad1. Added a new `HintMode::IntroProse(&'static str)` variant that surfaces catalog prose at slot entry without suppressing Tab completion (unlike `ProseOnly`) and without requiring `typing_name_at_cursor` to fire (unlike `ForceProse`). Wrapped ELEMENT in `Node::Hinted { mode: IntroProse("hint.create_table_element"), … }`. At `create table T (` the ambient hint now reads: *"Type a column name, or a table-level constraint: `primary`, `unique`, `check`, `constraint`, `foreign`"* — column name is the dominant first move; the constraint alternatives are folded into the prose. Tab still cycles every keyword. The new variant is an additive extension to the ADR-0024 HintMode-per-node model; no behaviour change to existing modes.
Sign in to join this conversation.