Grammar: with-pk column specs use name(type), matching add column
`create table … with pk` parsed column types as `name:type`,
while `add column` uses `name(type)`. Unify on the parens
form so column-type syntax is consistent across the DSL:
create table T with pk id(serial), name(text)
Only `COL_SPEC` changes (`:` → `( … )`); `build_create_table`
reads columns by role, so it is unaffected. The `:` that
separates table from column in `add column` / `drop column`
is unchanged. Sweeps the test suite, the typing-surface
matrix (two `after_colon` cells renamed to `after_paren`,
4 snapshots regenerated), the friendly catalog's usage
templates, ADR-0009's example, and requirements.md.
1039 passing / 0 failing / 1 ignored; clippy clean.
This commit is contained in:
@@ -796,7 +796,7 @@ pub static CHANGE: CommandNode = CommandNode {
|
||||
usage_ids: &["parse.usage.change_column"],};
|
||||
|
||||
// =================================================================
|
||||
// create_table — `create table <Name> [with pk [<col>:<type>[, ...]]]`
|
||||
// create_table — `create table <Name> [with pk [<col>(<type>)[, ...]]]`
|
||||
// (Phase C)
|
||||
// =================================================================
|
||||
|
||||
@@ -816,7 +816,7 @@ const COL_NAME: Node = Node::Hinted {
|
||||
|
||||
const COL_SPEC_NODES: &[Node] = &[
|
||||
COL_NAME,
|
||||
Node::Punct(':'),
|
||||
Node::Punct('('),
|
||||
Node::Ident {
|
||||
source: IdentSource::Types,
|
||||
role: "col_type",
|
||||
@@ -826,6 +826,7 @@ const COL_SPEC_NODES: &[Node] = &[
|
||||
writes_column: false,
|
||||
writes_user_listed_column: false,
|
||||
},
|
||||
Node::Punct(')'),
|
||||
];
|
||||
const COL_SPEC: Node = Node::Seq(COL_SPEC_NODES);
|
||||
|
||||
@@ -884,7 +885,7 @@ fn build_create_table(path: &MatchedPath) -> Result<Command, ValidationError> {
|
||||
|
||||
let pk_specs: Vec<(String, Type)> = if names.is_empty() {
|
||||
if saw_with {
|
||||
// `with pk` alone — default to id:serial.
|
||||
// `with pk` alone — default to id(serial).
|
||||
vec![("id".to_string(), Type::Serial)]
|
||||
} else {
|
||||
return Err(ValidationError {
|
||||
|
||||
Reference in New Issue
Block a user