Skip to content

Store NumPy booleans as SQLite integers - #975

Open
ShianMike wants to merge 2 commits into
simonw:mainfrom
ShianMike:fix/numpy-boolean-scalars
Open

ShianMike wants to merge 2 commits into
simonw:mainfrom
ShianMike:fix/numpy-boolean-scalars

Conversation

@ShianMike

@ShianMike ShianMike commented Nov 30, 2026 •

Copy link
Copy Markdown

Fixes #974.

NumPy boolean scalars now follow Python booleans for both column type inference and SQLite parameter binding. Inferred columns containing NumPy booleans, including when mixed with Python booleans, use INTEGER affinity. An explicit np.bool_ schema type also maps to INTEGER.

The regression cases cover newly inferred columns, mixed values, and explicit Python and NumPy boolean schema types. All four failed on main and pass with this change. A separate SQL check confirmed that WHERE enabled = 1 now matches the stored true value.

Verification

  • Python 3.14.0, SQLite 3.50.4, NumPy 2.5.5. uv run --no-sync pytest -q -rs returned 1,633 passed and 17 skips for platform or optional dependencies.
  • Python 3.11.14 without NumPy. pytest tests/test_create.py tests/test_utils.py -q returned 236 passed and 6 skips.
  • Black, Flake8, mypy, and Pyright passed.

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-30T08:28:27.191441Z 0cc1b0d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0cc1b0db99

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sqlite_utils/db.py Resolved

@atishay-kasliwal atishay-kasliwal left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inserted np.bool_ values with insert_all, row-by-row insert, mixed with Python bool, and through upsert. They're now stored as integer 0 / 1 in an INTEGER column. Master raised KeyError: <class 'numpy.bool'> when creating the table, and into an existing column it wrote np.bool_(False) as the blob b'\x00'. NumPy ints and floats and pandas bool columns are unchanged.

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.

NumPy booleans are stored as BLOBs or raise during table inference

2 participants