Skip to content

feat: DML/DDL writes with autocommit and --read-only safe mode - #28

Merged
fsistemas merged 1 commit into
masterfrom
feature/FRA-266
Jun 25, 2026
Merged

feat: DML/DDL writes with autocommit and --read-only safe mode#28
fsistemas merged 1 commit into
masterfrom
feature/FRA-266

Conversation

@fsistemas

Copy link
Copy Markdown
Owner

Summary

Adds write support to the single default command and an opt-in safe mode.

  • Autocommit writes: INSERT/UPDATE/DELETE/DDL now commit by default and return {"rowcount": N} (previously raised ResourceClosedError). SELECT / ... RETURNING return rows through the transform pipeline as before.
  • Consistent rowcount: clamped with max(rowcount, 0), so DDL / "count unknown" statements report {"rowcount": 0} uniformly across SQLite, PostgreSQL and MySQL (drivers otherwise vary: -1 vs 0).
  • --read-only safe mode (default off): the statement runs but nothing persists — a real read-only transaction is requested where supported (SQLite PRAGMA query_only, PG/MySQL SET 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

  • Unit tests on file-backed SQLite (tests/test_write.py) for autocommit persistence, read-only, wrapper-on-rowcount, and _coerce_bool.
  • Integration tests for the write + read-only path against real PostgreSQL and MySQL, including the SET TRANSACTION READ ONLY branch and DDL rowcount consistency.
  • Read-only verified live across sqlite/postgres/mysql.

Docs

README, AGENTS.md, CLAUDE.md, SKILL.md and CHANGELOG updated for the autocommit + --read-only contract.

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.
@fsistemas
fsistemas merged commit f016455 into master Jun 25, 2026
6 checks passed
@fsistemas
fsistemas deleted the feature/FRA-266 branch June 25, 2026 01:40
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