Skip to content

Support explicit SQL function deregistration - #906

Open
goingforstudying-ctrl wants to merge 2 commits into
simonw:mainfrom
goingforstudying-ctrl:sql-function-deregistration-20261014
Open

goingforstudying-ctrl wants to merge 2 commits into
simonw:mainfrom
goingforstudying-ctrl:sql-function-deregistration-20261014

Conversation

@goingforstudying-ctrl

@goingforstudying-ctrl goingforstudying-ctrl commented Oct 14, 2026 •

Copy link
Copy Markdown

Migration callbacks can now be deregistered with Database.register_function(fn, deregister=True), using the API sketched in the owner prototype. The original callable stops being invoked, and its tracked name/arity is cleared so ordinary re-registration works without replace=True.

Only registrations tracked by this Database instance are affected. Unknown or already-cleared signatures are no-ops, preserving built-in SQL functions and callbacks registered directly on the connection. Aliases, SQLite's ASCII case matching, non-ASCII names and distinct arity overloads are covered; cache entries are retained if SQLite rejects the operation. Existing registration defaults and decorator return behavior are preserved, with no new dependencies.

Deregistration delegates to create_function(name, arity, None). Some Python bindings retain a None placeholder that raises OperationalError and can report an unraisable TypeError when callback tracebacks are enabled. The API documentation states this limitation, and tests capture and validate the expected driver error; the feature does not promise catalog-entry deletion or restoration of an overridden function. The context manager and CLI changes remain outside this patch. Refs #589.

Validation on Python 3.11/macOS with network disabled:

  • Focused registration suite: 18 passed, including regressions preserving built-ins and directly registered callbacks.
  • Full suite: 1,507 passed, 18 skipped. Expected placeholder errors are checked explicitly; existing Click deprecation warnings remain.
  • Black, Flake8 (one worker), mypy across sqlite_utils and tests, and the new RST section: passed.

📚 Documentation preview 📚: https://sqlite-utils--906.org.readthedocs.build/en/906/

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