Skip to content

feat(registry): validate link columns - #56

Closed
msto wants to merge 1 commit into
feat/registry-validate-array-linkfrom
feat/registry-validate-link
Closed

msto wants to merge 1 commit into
feat/registry-validate-array-linkfrom
feat/registry-validate-link

Conversation

@msto

@msto msto commented May 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

Related to #42. Stacked on #51. Tracked at #53.

Extends _compare_unwrapped with a dispatch branch for
LatchRecordModel subclasses, plus _compare_link.

  • Per spec, the link's target table is not checked — any
    LatchRecordModel subclass matches any link column, keeping the
    check tolerant of models that represent only a subset of a larger
    linked table. The SDK's to_python_type maps link columns to
    Record, so a column is a link iff column_type is Record.
  • _looks_like_latch_record_model is a structural check (per
    your review): instead of issubclass(t, LatchRecordModel) —
    which would force a lazy local import to avoid the circular
    _record_model ↔ _schema dependency — it verifies that t is a
    Pydantic BaseModel subclass with the id and name fields
    LatchRecordModel mandates. A dedicated test confirms an unrelated
    BaseModel without those fields is NOT treated as a link.

Split out of the original combined array+link PR per your request.

Test plan

  • Happy path with a typed LatchRecordModel subclass.
  • Happy path with the bare LatchRecordModel base.
  • Model declares a record subclass but column is a string primitive
    → TYPE_MISMATCH.
  • RecordSubclass | None ↔ nullable link column happy path.
  • An unrelated BaseModel (no id/name) does NOT get treated as
    a link — surfaces as a primitive TYPE_MISMATCH.

Co-Authored-By: Claude noreply@anthropic.com

Extends `_compare_unwrapped` with a dispatch branch for
`LatchRecordModel` subclasses, plus `_compare_link`.

Per spec, the link's target table is not checked — any
`LatchRecordModel` subclass matches any `link` column, keeping the
check tolerant of models that represent only a subset of a larger
linked table. The SDK's `to_python_type` maps link columns to
`Record`, so a column is a link iff `column_type is Record`.

**`_looks_like_latch_record_model` is a structural check** (per
@msto's review): instead of `issubclass(t, LatchRecordModel)` —
which would force a lazy local import to avoid the circular
`_record_model` ↔ `_schema` dependency — it verifies that `t` is a
Pydantic `BaseModel` subclass with the `id` and `name` fields
`LatchRecordModel` mandates. A dedicated test confirms an unrelated
`BaseModel` without those fields is NOT treated as a link.

Split out of the original combined array+link PR per @msto's request.

Related to #42. Tracked at #53.
@msto
msto force-pushed the feat/registry-validate-link branch from 54069bb to 4d29545 Compare May 21, 2026 19:27
@msto msto closed this Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant