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].
7
7
8
8
## Unreleased
9
9
10
+ - changed: raise if an in memory database is opened with a pool_size != 1
11
+
10
12
## v0.11.0
11
13
12
14
- added: Support for DDL transactions.
Original file line number Diff line number Diff line change @@ -210,6 +210,7 @@ defmodule Ecto.Adapters.SQLite3 do
210
210
@ impl Ecto.Adapter.Storage
211
211
def storage_up ( options ) do
212
212
database = Keyword . get ( options , :database )
213
+ pool_size = Keyword . get ( options , :pool_size )
213
214
214
215
cond do
215
216
is_nil ( database ) ->
@@ -226,6 +227,11 @@ defmodule Ecto.Adapters.SQLite3 do
226
227
File . exists? ( database ) ->
227
228
{ :error , :already_up }
228
229
230
+ database == ":memory:" && pool_size != 1 ->
231
+ raise ArgumentError , """
232
+ In memory databases must have a pool_size of 1
233
+ """
234
+
229
235
true ->
230
236
{ :ok , state } = Exqlite.Connection . connect ( options )
231
237
: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
47
47
fn -> SQLite3 . storage_up ( mumble: "no database here" ) == :ok end
48
48
)
49
49
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
50
64
end
51
65
52
66
describe ".storage_down/2" do
You can’t perform that action at this time.
0 commit comments