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:
claude@clouddev1
2026-05-18 21:51:52 +00:00
parent 9aa7e2ede0
commit d9a98bbd49
20 changed files with 68 additions and 67 deletions
+7 -7
View File
@@ -393,7 +393,7 @@ mod tests {
#[test]
fn create_table_with_named_typed_pk() {
assert_eq!(
ok("create table Customers with pk email:text"),
ok("create table Customers with pk email(text)"),
Command::CreateTable {
name: "Customers".to_string(),
columns: vec![col("email", Type::Text)],
@@ -405,7 +405,7 @@ mod tests {
#[test]
fn create_table_with_compound_pk() {
assert_eq!(
ok("create table OrderLines with pk order_id:int,product_id:int"),
ok("create table OrderLines with pk order_id(int),product_id(int)"),
Command::CreateTable {
name: "OrderLines".to_string(),
columns: vec![col("order_id", Type::Int), col("product_id", Type::Int),],
@@ -417,7 +417,7 @@ mod tests {
#[test]
fn create_table_pk_accepts_any_user_type() {
for ty in Type::all() {
let input = format!("create table T with pk col:{}", ty.keyword());
let input = format!("create table T with pk col({})", ty.keyword());
let cmd = ok(&input);
if let Command::CreateTable {
columns,
@@ -436,7 +436,7 @@ mod tests {
#[test]
fn create_table_pk_tolerates_whitespace() {
assert_eq!(
ok("create table T with pk id : serial"),
ok("create table T with pk id ( serial )"),
Command::CreateTable {
name: "T".to_string(),
columns: vec![col("id", Type::Serial)],
@@ -444,7 +444,7 @@ mod tests {
}
);
assert_eq!(
ok("create table T with pk a : int , b : int"),
ok("create table T with pk a ( int ) , b ( int )"),
Command::CreateTable {
name: "T".to_string(),
columns: vec![col("a", Type::Int), col("b", Type::Int)],
@@ -456,7 +456,7 @@ mod tests {
#[test]
fn create_table_keywords_are_case_insensitive() {
assert_eq!(
ok("CREATE TABLE Customers WITH PK email:TEXT"),
ok("CREATE TABLE Customers WITH PK email(TEXT)"),
Command::CreateTable {
name: "Customers".to_string(),
columns: vec![col("email", Type::Text)],
@@ -760,7 +760,7 @@ mod tests {
#[test]
fn unknown_pk_type_errors_with_alternatives_listed() {
let e = err("create table T with pk id:varchar");
let e = err("create table T with pk id(varchar)");
match e {
ParseError::Invalid { message, .. } => {
assert!(message.contains("varchar"), "{message}");