feat: DML/DDL writes with autocommit and --read-only safe mode - #28
Merged
Conversation
Non-row statements (INSERT/UPDATE/DELETE/DDL) now commit by default and
return {"rowcount": N}, clamped to 0 so DDL is consistent across databases.
Add --read-only to run a statement without persisting it. Covered by unit
and PostgreSQL/MySQL integration tests; docs updated.
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.
Summary
Adds write support to the single default command and an opt-in safe mode.
{"rowcount": N}(previously raisedResourceClosedError). SELECT /... RETURNINGreturn rows through the transform pipeline as before.max(rowcount, 0), so DDL / "count unknown" statements report{"rowcount": 0}uniformly across SQLite, PostgreSQL and MySQL (drivers otherwise vary:-1vs0).--read-onlysafe mode (default off): the statement runs but nothing persists — a real read-only transaction is requested where supported (SQLitePRAGMA query_only, PG/MySQLSET TRANSACTION READ ONLY) with an unconditional rollback backstop. A write prints a stderr notice and returns a rowcount dict without persisting; SELECT returns rows normally.Tests
tests/test_write.py) for autocommit persistence, read-only, wrapper-on-rowcount, and_coerce_bool.SET TRANSACTION READ ONLYbranch and DDL rowcount consistency.Docs
README, AGENTS.md, CLAUDE.md, SKILL.md and CHANGELOG updated for the autocommit +
--read-onlycontract.