refactor: ColumnSpec / AddColumn carry constraint fields (ADR-0029 scaffolding)

Expand ColumnSpec and Command::AddColumn with the four
ADR-0029 constraint slots (not_null, unique, default, check),
all defaulting off; `Database::add_column` now takes a
ColumnSpec. No behaviour change — the grammar to set the
fields and the DDL to enforce them land in the following
commits. Isolated here so those commits stay readable.

Adds ColumnSpec::new for the unconstrained case; 110 call
sites updated. 1172 tests pass; clippy clean.
This commit is contained in:
claude@clouddev1
2026-05-19 14:04:36 +00:00
parent 7bfd213ab3
commit eff2ee8d14
15 changed files with 237 additions and 194 deletions
+17 -17
View File
@@ -45,8 +45,8 @@ fn enrich_unique_insert_resolves_table_column_value_and_pinpoint() {
db.create_table(
"Customers".to_string(),
vec![
ColumnSpec { name: "id".to_string(), ty: Type::Int },
ColumnSpec { name: "name".to_string(), ty: Type::Text },
ColumnSpec::new("id".to_string(), Type::Int),
ColumnSpec::new("name".to_string(), Type::Text),
],
vec!["id".to_string()],
None,
@@ -109,7 +109,7 @@ fn enrich_unique_insert_natural_order_short_form_resolves_value_via_schema() {
rt().block_on(async {
db.create_table(
"thing".to_string(),
vec![ColumnSpec { name: "id".to_string(), ty: Type::Int }],
vec![ColumnSpec::new("id".to_string(), Type::Int)],
vec!["id".to_string()],
None,
)
@@ -152,8 +152,8 @@ fn enrich_unique_update_resolves_value_from_assignments() {
db.create_table(
"Customers".to_string(),
vec![
ColumnSpec { name: "id".to_string(), ty: Type::Int },
ColumnSpec { name: "name".to_string(), ty: Type::Text },
ColumnSpec::new("id".to_string(), Type::Int),
ColumnSpec::new("name".to_string(), Type::Text),
],
vec!["id".to_string()],
None,
@@ -215,8 +215,8 @@ fn enrich_not_null_resolves_table_and_column() {
db.create_table(
"T".to_string(),
vec![
ColumnSpec { name: "a".to_string(), ty: Type::Int },
ColumnSpec { name: "b".to_string(), ty: Type::Text },
ColumnSpec::new("a".to_string(), Type::Int),
ColumnSpec::new("b".to_string(), Type::Text),
],
vec!["a".to_string(), "b".to_string()],
None,
@@ -258,7 +258,7 @@ fn enrich_fk_insert_resolves_parent_table_column_and_value() {
rt().block_on(async {
db.create_table(
"Customers".to_string(),
vec![ColumnSpec { name: "id".to_string(), ty: Type::Int }],
vec![ColumnSpec::new("id".to_string(), Type::Int)],
vec!["id".to_string()],
None,
)
@@ -267,8 +267,8 @@ fn enrich_fk_insert_resolves_parent_table_column_and_value() {
db.create_table(
"Orders".to_string(),
vec![
ColumnSpec { name: "id".to_string(), ty: Type::Int },
ColumnSpec { name: "CustId".to_string(), ty: Type::Int },
ColumnSpec::new("id".to_string(), Type::Int),
ColumnSpec::new("CustId".to_string(), Type::Int),
],
vec!["id".to_string()],
None,
@@ -333,7 +333,7 @@ fn enrich_fk_insert_natural_order_multi_value_resolves_via_schema() {
rt().block_on(async {
db.create_table(
"Customers".to_string(),
vec![ColumnSpec { name: "id".to_string(), ty: Type::Int }],
vec![ColumnSpec::new("id".to_string(), Type::Int)],
vec!["id".to_string()],
None,
)
@@ -342,9 +342,9 @@ fn enrich_fk_insert_natural_order_multi_value_resolves_via_schema() {
db.create_table(
"Orders".to_string(),
vec![
ColumnSpec { name: "id".to_string(), ty: Type::Serial },
ColumnSpec { name: "CustId".to_string(), ty: Type::Int },
ColumnSpec { name: "Total".to_string(), ty: Type::Real },
ColumnSpec::new("id".to_string(), Type::Serial),
ColumnSpec::new("CustId".to_string(), Type::Int),
ColumnSpec::new("Total".to_string(), Type::Real),
],
vec!["id".to_string()],
None,
@@ -408,7 +408,7 @@ fn enrich_fk_delete_resolves_child_table() {
rt().block_on(async {
db.create_table(
"Customers".to_string(),
vec![ColumnSpec { name: "id".to_string(), ty: Type::Int }],
vec![ColumnSpec::new("id".to_string(), Type::Int)],
vec!["id".to_string()],
None,
)
@@ -417,8 +417,8 @@ fn enrich_fk_delete_resolves_child_table() {
db.create_table(
"Orders".to_string(),
vec![
ColumnSpec { name: "id".to_string(), ty: Type::Int },
ColumnSpec { name: "CustId".to_string(), ty: Type::Int },
ColumnSpec::new("id".to_string(), Type::Int),
ColumnSpec::new("CustId".to_string(), Type::Int),
],
vec!["id".to_string()],
None,