Skip to main content

declare_relation

Function declare_relation 

Source
pub fn declare_relation(
    catalog: &Catalog,
    spec: &Value,
    from_table_handle: &Table,
    to_table_handle: &Table,
    now: u64,
    force: bool,
) -> Result<Catalog, HaysonSchemaError>
Expand description

db.declareRelation() — adds a named relation to the catalog. Mirrors declare_index’s shape: parses and validates against the catalog held in memory, refuses without writing anything, and leaves write_catalog to the caller.

When the new relation declares enforce: true, this additionally runs the same orphan check checkIntegrity does (catalog::integrity::check_integrity, scoped to just this relation) and refuses — unless force is true — if any live record already breaks it: turning enforcement on does not retroactively catch what was written before it existed, so declaring it silently over existing orphans would make a promise the data has already broken. force: true accepts that and declares anyway; the orphans already there stay orphans, enforcement starts from here.