File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ project adheres to [Semantic Versioning][semver].
77
88## Unreleased
99
10+ - changed: raise if an in memory database is opened with a pool_size != 1
11+
1012## v0.11.0
1113
1214- added: Support for DDL transactions.
Original file line number Diff line number Diff line change @@ -210,6 +210,7 @@ defmodule Ecto.Adapters.SQLite3 do
210210 @ impl Ecto.Adapter.Storage
211211 def storage_up ( options ) do
212212 database = Keyword . get ( options , :database )
213+ pool_size = Keyword . get ( options , :pool_size )
213214
214215 cond do
215216 is_nil ( database ) ->
@@ -226,6 +227,11 @@ defmodule Ecto.Adapters.SQLite3 do
226227 File . exists? ( database ) ->
227228 { :error , :already_up }
228229
230+ database == ":memory:" && pool_size != 1 ->
231+ raise ArgumentError , """
232+ In memory databases must have a pool_size of 1
233+ """
234+
229235 true ->
230236 { :ok , state } = Exqlite.Connection . connect ( options )
231237 :ok = Exqlite.Connection . disconnect ( :normal , state )
Original file line number Diff line number Diff line change @@ -47,6 +47,20 @@ defmodule Ecto.Adapters.SQLite3ConnTest do
4747 fn -> SQLite3 . storage_up ( mumble: "no database here" ) == :ok end
4848 )
4949 end
50+
51+ test "can create an in memory database" do
52+ assert SQLite3 . storage_up ( database: ":memory:" , pool_size: 1 ) == :ok
53+ end
54+
55+ test "fails if in memory database does not have a pool size of 1" do
56+ assert_raise (
57+ ArgumentError ,
58+ """
59+ In memory databases must have a pool_size of 1
60+ """ ,
61+ fn -> SQLite3 . storage_up ( database: ":memory:" , pool_size: 2 ) end
62+ )
63+ end
5064 end
5165
5266 describe ".storage_down/2" do
You can’t perform that action at this time.
0 commit comments