fix(database): suggest closest supported type on schema typos#264
Merged
Conversation
A new user typing ``BIGINTEGER`` (mixing MySQL's BIGINT with Python's
``int``), ``BOLEAN`` (missing an O), ``NUMRIC`` (missing an E), etc.
used to get a bare ``Unsupported MySQL type: <typo>`` error with no
hint about what's actually supported. They'd have to spelunk the
schema docs or guess.
## Fix
Add a Levenshtein-based "Did you mean X?" hint to ``_get_sqlalchemy_type``'s
ValueError. The threshold (d ≤ 3) is the empirical sweet spot:
- close enough to catch every realistic typo we've seen in adversarial
testing (single-letter swap, missing letter, repeated letter,
common prefix/suffix confusion)
- wide enough to fail-silently on genuine unrelated types (a real
``GEOMETRY`` request stays "Unsupported" with no misleading hint)
The error ALSO prints the full supported-type list so:
- the suggestion gets the user 80% of the way there
- the list catches the cases where the closest-by-distance suggestion
isn't the closest-by-intent (e.g. BIGINTEGER's nearest by edits is
INTEGER (d=3), even though the user clearly wanted BIGINT (d=4) —
the printed list has BIGINT right next to INTEGER)
## Tests
- ``test_get_sqlalchemy_type_typo_suggests_correction``: BIGINTEGER
surfaces the INTEGER suggestion + the BIGINT alternative is in the
supported list
- ``test_get_sqlalchemy_type_typo_no_suggestion_for_distant_input``:
GEOMETRY (d=6 to nearest) gets no hint, only the supported list
- Parametrised cases over realistic typos: INTGER→INTEGER, NUMRIC→NUMERIC,
BOLEAN→BOOLEAN, VARCAHR→VARCHAR
## Surfaced by
Adversarial new-user test pass against v0.3.10-rc2, scenario N3:
``BIGINTEGER`` got a bare unhelpful error.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Collaborator
|
👋 Heads-up — Code review queue is at 15 / 8 Above the WIP limit. The team convention is to review existing PRs before opening new work. Open PRs currently in Code review (oldest first):
Pull from review before opening new work. (This is a nudge from the kanban WIP check, not a block.) |
aptracebloc
approved these changes
Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A new user typing
BIGINTEGER(mixing BIGINT with Python'sint),BOLEAN(missing O),NUMRIC(missing E), etc. used to get a bareUnsupported MySQL type: <typo>error with no hint. They had to spelunk the schema docs or guess.Fix
Levenshtein-based "Did you mean X?" hint in
_get_sqlalchemy_type's ValueError. Threshold d ≤ 3 — close enough to catch realistic typos (BIGINTEGER, INTGER, NUMRIC, BOLEAN, VARCAHR), narrow enough that GEOMETRY (d=6 to nearest) gets no misleading hint.The error also prints the full supported-type list, so cases where edit-distance-nearest ≠ intent-nearest (e.g. BIGINTEGER's nearest by edits is INTEGER, even though the user clearly wanted BIGINT) still get help — BIGINT is right there in the list.
Test plan
Surfaced by adversarial new-user testing N3 (parent #261).
🤖 Generated with Claude Code
Note
Low Risk
Only changes error text for invalid schema types; valid type mapping and DDL behavior are unchanged.
Overview
Unsupported MySQL type strings in user schemas now get actionable
ValueErrormessages instead of a bare "Unsupported" line._get_sqlalchemy_typecalls a new_suggest_typehelper (Levenshtein distance ≤ 3 againsttype_mappingkeys). Close typos likeBIGINTEGER,INTGER, orNUMRICraise Did you mean '…'? plus a Supported types: list sorted from the mapping. Distant names such asGEOMETRYstill fail without a misleading suggestion.Tests cover the suggestion path, the no-suggestion path, and a parametrized set of common misspellings.
Reviewed by Cursor Bugbot for commit 6088793. Bugbot is set up for automated code reviews on this repo. Configure here.