Skip to content

Schema: value types (structured attribute types, lists) #11

Description

@jbeda

The gap

Attribute types are lowercase primitives (string, integer, boolean, timestamp) or the name of a defined enum. Relationship targets must be entities. That leaves no home for a value type: a structured value with internal shape and validity rules that is not an entity (no identity, no lifecycle) but is more than a primitive.

Motivating example, from modeling a diagram tool. An arrow endpoint anchors to a target through a normalized point:

glossary:
  FixedPoint: >-
    A normalized (u, v) point in the unit square that scales with its
    target's box. (0.5, 0.5) is the center; a coordinate at 0 or 1 lies
    on an edge. Values outside the unit square are invalid.

FixedPoint has structure (two components) and a validity range, but the only place it can live is the glossary as prose. No attribute can be typed as one. Promoting it to an entity would be worse: it would acquire identity and ER-diagram presence it does not deserve.

Lists hit the same wall. An arrow's waypoints (an ordered list of points) cannot be an attribute at all; there is no collection type.

Possible shape

A top-level types: (or values:) section, sibling to enums, defining named value types with fields and constraints; attribute type accepts them. A list of X type form (or repeated: true on an attribute) covers collections. Lint already warns on PascalCase types that name no enum; the same check would resolve against value types too.

Workaround today

Glossary prose for the shape, and either dropping the attribute or mistyping it as string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions