create table: column constraints — NOT NULL / UNIQUE / DEFAULT grammar (ADR-0029)
`create table … with pk` now parses the column-constraint suffix; combined with the commit-1 db layer, a constrained table works end to end. - A shared constraint-suffix grammar fragment — `not null`, `unique`, `default <literal>` — sits after each column's `(type)` group; `build_create_table` walks the matched path per column and folds the constraints into `ColumnSpec`. - §9 redundancy check: every `with pk` column is a primary-key column, so `not null` (any) and `unique` (single-column PK) are rejected with a friendly error (`parse.custom.constraint_redundant_on_pk`). - `project.yaml` round-trip: `ColumnSchema` gains `not_null` / `default`; the YAML reader/writer and `build_read_schema` carry them, so `rebuild` / `export` / `import` preserve constraints. - ADR-0029 §2.1's example corrected — `create table` columns are all PK columns, so its suffix is for `default` / `check`; `docs/simple-mode-limitations.md` records that non-PK columns at create time need advanced mode. CHECK is deferred to the next commit. 1184 tests pass (+7); clippy clean.
This commit is contained in:
@@ -375,7 +375,10 @@ fn require_ident(path: &MatchedPath, role: &'static str) -> Result<String, Valid
|
||||
/// Convert a `MatchedItem` whose kind is one of the `value_literal`
|
||||
/// variants (Word("null"|"true"|"false"), NumberLit, StringLit) to
|
||||
/// a `Value`. Returns None for non-value items.
|
||||
fn item_to_value(item: &MatchedItem) -> Option<Value> {
|
||||
///
|
||||
/// `pub(crate)` so `grammar::ddl` can reuse it when collecting a
|
||||
/// `default <literal>` column constraint (ADR-0029).
|
||||
pub(crate) fn item_to_value(item: &MatchedItem) -> Option<Value> {
|
||||
match &item.kind {
|
||||
MatchedKind::Word("null") => Some(Value::Null),
|
||||
MatchedKind::Word("true") => Some(Value::Bool(true)),
|
||||
|
||||
Reference in New Issue
Block a user