Skip to content

refactor: move adapter models to the native core - #381

Merged
kvlonge merged 3 commits into
mainfrom
refactor/native-adapter-models
Nov 11, 2026
Merged

kvlonge merged 3 commits into
mainfrom
refactor/native-adapter-models

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Why

The adapter models were the last movable Python in SQLTide. Moving them into the native core makes the Python package a thin wrapper and brings the Python boundary's remaining_lines from 1080 to 0.

Two copy-protocol gaps in native shapes are also closed. copy.copy rebuilt shapes through the constructor, so mappings and tuples in the copy were new objects. copy.replace failed on Python 3.13 and later, although the previous dataclasses supported it there.

Changes

  • All 86 adapter connection, catalog, query, replay, deployment and warehouse shapes are native classes; adapter/models.py only re-exports them.
  • The adapter enums stay in sqltide.adapter.types and are coerced in the previous order, including AdapterWarehouseHealth's.
  • The connection config repr and str still redact the password, and named_rows keeps its strict zip errors.
  • copy.copy of a native shape shares the original's field values, without running coercion or post-init checks again. Python subclasses keep their type and instance dictionary. deepcopy and pickle are unchanged.
  • Native shapes define __replace__ through dataclasses.replace, so copy.replace coerces and validates the replaced fields again.
  • python-boundary.toml: remaining_lines = 0.

Verification

  • Randomized differential tests against the 0.65.13 release: 1,500 cases per seed over seeds 1 to 6 found no differences. Every planted repr, coercion, property, method and copy mutation was detected.
  • Shallow-copy field sharing, __replace__ and the exact redacted repr are covered by unit tests that also pass on 0.65.13.
  • Under Python 3.13, copy.replace gives the same results and errors as 0.65.13, apart from the wording of a misuse error.
  • sqt discover/sqt compile CLI output and dev-server JSON match 0.65.13.
  • Compiler (18/18) and planner (8/8) goldens are unedited and match. The shape surface baseline is unchanged.
  • make check-ci and the full unit suite pass.

copy.copy of a native shape now reuses the instance's field values
instead of rebuilding it through the constructor, so coerced mappings and
tuples are the same objects in the copy, as they were for the previous
dataclasses. Post-init checks do not run again, Python subclasses keep
their type and instance dictionary, and deepcopy and pickle are unchanged.
The adapter connection, catalog, query, replay, deployment and warehouse
shapes are native classes and adapter/models.py re-exports them. The
connection config repr still redacts the password, and named_rows keeps
its strict zip errors. No movable Python remains: remaining_lines is 0.
Native shapes now define __replace__ through dataclasses.replace, so
copy.replace works on Python 3.13 and later as it did for the previous
dataclasses, coercing and validating the replaced fields again.
@kvlonge
kvlonge enabled auto-merge (squash) November 11, 2026 06:19
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Deploying sqltide with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5247bd3
Status: ✅  Deploy successful!
Preview URL: https://fd257cc2.sqltide.pages.dev
Branch Preview URL: https://wip-native-adapter-models-3.sqltide.pages.dev

View logs

@kvlonge
kvlonge merged commit 1acf514 into main Nov 11, 2026
17 checks passed
@kvlonge
kvlonge deleted the refactor/native-adapter-models branch November 11, 2026 06:48
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