Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/exqlite/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ defmodule Exqlite.Connection do
end

defp set_journal_mode(db, options) do
maybe_set_pragma(db, "journal_mode", Pragma.journal_mode(options))
set_pragma_if_present(db, "journal_mode", Keyword.get(options, :journal_mode))
end

defp set_temp_store(db, options) do
Expand Down
12 changes: 12 additions & 0 deletions test/exqlite/connection_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,18 @@ defmodule Exqlite.ConnectionTest do
assert {:error, "attempt to write a readonly database"} ==
Sqlite3.execute(ro_state.db, insert_value_query)
end

test "preserves WAL mode across connections" do
path = Temp.path!()

{:ok, state1} = Connection.connect(database: path, journal_mode: :wal)
assert {:ok, "wal"} = get_pragma(state1.db, :journal_mode)

{:ok, state2} = Connection.connect(database: path)
assert {:ok, "wal"} = get_pragma(state2.db, :journal_mode)

File.rm(path)
end
end

defp get_pragma(db, pragma_name) do
Expand Down