Skip to content

feat: finer-grained :mode support for Sqlite3.open (align with sqlite3_open_v2)#348

Open
dl-alexandre wants to merge 1 commit into
elixir-sqlite:mainfrom
dl-alexandre:feat/align-mode-with-sqlite-open-v2
Open

feat: finer-grained :mode support for Sqlite3.open (align with sqlite3_open_v2)#348
dl-alexandre wants to merge 1 commit into
elixir-sqlite:mainfrom
dl-alexandre:feat/align-mode-with-sqlite-open-v2

Conversation

@dl-alexandre
Copy link
Copy Markdown
Contributor

Summary

This change adds finer-grained control over the :mode option (why: to align the public API with the underlying sqlite3_open_v2 flags as proposed and welcomed by the maintainer in #347, while preserving backward compat for the common case).

Add finer-grained control over the :mode option when opening SQLite databases via Sqlite3.open/2 (and thus Exqlite.start_link/1 etc.).

This implements the alignment with sqlite3_open_v2 flags proposed in #347. The maintainer indicated openness to the change (preferring to keep the ergonomic default via lists).

Changes

  • :readwrite atom form is preserved for backward compatibility (still implies CREATE).
  • List forms now give precise control without implicit CREATE:
    • mode: [:readwrite] — read/write only (will fail to open non-existing files).
    • mode: [:readwrite, :create] — the previous "default" behavior.
    • :create is now a first-class list element.
    • Other combinations (:nomutex, etc.) continue to work.
  • Updated @type, docs, error messages, and added a regression test.
  • Changelog entry.

This is non-breaking for the common mode: :readwrite / default usage while enabling the use-case from the issue (and URI ?mode=rw etc. documented behavior).

Validation

  • mix test (sqlite3 mode tests + connection tests)
  • New test exercises [:readwrite] (no create) vs. default atom and explicit create list.

Refs #347

@warmwaffles
Copy link
Copy Markdown
Member

You've got a merge conflict on the change log. Should be easy to rectify. Rebase off of main and adjust the entry up into the unreleased section. Sorry I cut a release yesterday.

…3_open_v2)

- `:readwrite` atom keeps backward-compatible "create if needed" behavior.
- Lists now allow precise control:
  - `[:readwrite]` for read/write without CREATE (errors if file missing).
  - `[:readwrite, :create]` (or default list form) for with create.
  - `:create` supported in lists.
- Updated types, docs, error messages, and tests.
- Added test covering no-create list vs compat default.

Refs elixir-sqlite#347 (proposal accepted in spirit by maintainer @warmwaffles).

This is a non-breaking enhancement for users who opt into list forms.
@dl-alexandre dl-alexandre force-pushed the feat/align-mode-with-sqlite-open-v2 branch from 345a9ea to 85c76ec Compare June 4, 2026 17:48
@dl-alexandre
Copy link
Copy Markdown
Contributor Author

Thanks @warmwaffles — rebased the branch onto latest main (v0.37 bump + sqlite 3.53.2 etc.), and moved the :mode entry up into the current ## Unreleased section. The PR should be clean for merge now. Let me know if anything else!

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.

2 participants