Skip to content

Fix KeyError when passing an unrecognized string type to create_table or add_column - #818

Open
ikatyal2110 wants to merge 1 commit into
simonw:mainfrom
ikatyal2110:fix/add-column-unknown-string-type
Open

Fix KeyError when passing an unrecognized string type to create_table or add_column#818
ikatyal2110 wants to merge 1 commit into
simonw:mainfrom
ikatyal2110:fix/add-column-unknown-string-type

Conversation

@ikatyal2110

@ikatyal2110 ikatyal2110 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Passing a valid SQLite type string not present in COLUMN_TYPE_MAPPING — such as "NUMERIC" or "ANY" — to create_table or add_column raises KeyError instead of using the string as-is. The documentation for both methods explicitly states that col_type accepts "a Python type such as str or a SQLite type string such as BLOB", so any string should be accepted and passed through to SQLite unchanged. The fix uses .get() on the mapping and falls back to the raw string when the type is an unrecognised string, leaving all existing behaviour unchanged.


Generated by Claude Code


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

… or add_column

Passing a valid SQLite type string that is not in COLUMN_TYPE_MAPPING, such as
NUMERIC or ANY, raised KeyError instead of being used as-is. The fix falls back
to the raw string value when the type is a string not present in the mapping,
matching the documented behaviour: col_type accepts Python types or SQLite type
strings.
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