elixir-sqlite / sqlite_ecto2

Sqlite3 adapter for Ecto 2.2.x
https://hex.pm/packages/sqlite_ecto2
MIT License
120 stars 33 forks source link

Cannot create in-memory temporary database with ":memory:" #208

Closed krisalyssa closed 6 years ago

krisalyssa commented 6 years ago

Mac OS X 10.13.4, Elixir 1.6.5, Erlang 20.3.6, SQLite 3.19.3, sqlite_ecto2 2.2.2.

I followed the tutorial at https://github.com/scouten/sqlite_ecto2/blob/master/docs/tutorial.md through the end of "Configuring Ecto", running mix ecto.create followed by mix test. Success.

Then I edited config/config.exs to use an in-memory temporary database, as described in the SQLite documentation at https://sqlite.org/c3ref/open.html:

config :blog, Blog.Repo,
  adapter: Sqlite.Ecto2,
  database: ":memory:"

This time, when I run mix ecto.create, I get an error:

craigc@samantha:~/Projects/blog$ mix ecto.create
** (MatchError) no match of right hand side value: {:ok, [[journal_mode: "memory"]]}
    lib/sqlite_ecto.ex:135: Sqlite.Ecto2.storage_up_with_path/2
    lib/mix/tasks/ecto.create.ex:40: anonymous fn/3 in Mix.Tasks.Ecto.Create.run/1
    (elixir) lib/enum.ex:737: Enum."-each/2-lists^foreach/1-0-"/2
    (elixir) lib/enum.ex:737: Enum.each/2
    (mix) lib/mix/task.ex:314: Mix.Task.run_task/3
    (mix) lib/mix/cli.ex:80: Mix.CLI.run_task/2
scouten commented 6 years ago

I'll review a patch if one comes for this, but … I'm not sure what would be the point of fixing this.

Wouldn't the in-memory database created via mix ecto.create be discarded before it could be used in mix test?

krisalyssa commented 6 years ago

Oh. You're right. /dopeslap