gavares

gavares

Ecto.Adapters.SQL.Sandbox.child_spec/1 is undefined or private

I’m trying to use Commanded with Phoenix to create an eventsourced application. I’ve pieced things together from the conduit repo and the commanded docs but I’m getting a failure and stacktrace when I try to run my tests against my aggregate.

There is quite a bit of configuration, support code, and application code so I’m not sure which of that would be helpful to post here. Once my tests start, I’m getting error message:

** (UndefinedFunctionError) function Ecto.Adapters.SQL.Sandbox.child_spec/1 is undefined or private
     stacktrace:
       Ecto.Adapters.SQL.Sandbox.child_spec({Postgrex.Protocol, [types: Postgrex.DefaultTypes, username: "postgres", password: "password", database: "accounts_test", hostname: "localhost", pool: Ecto.Adapters.SQL.Sandbox, pool_size: 2]})
       (db_connection) lib/db_connection.ex:389: DBConnection.start_link/2
       (accounts) test/support/storage.ex:24: Accounts.Storage.reset_readstore/0
       (accounts) test/support/storage.ex:7: Accounts.Storage.reset!/0
       (ex_unit) lib/ex_unit/on_exit_handler.ex:142: ExUnit.OnExitHandler.exec_callback/1
       (ex_unit) lib/ex_unit/on_exit_handler.ex:128: ExUnit.OnExitHandler.on_exit_runner_loop/0

I’ve looked at db_connection.ex:389 and it’s not calling child_spec/1 so I’m very confused why this is happening. I’ve been trying to debug this for about 4 hours now and I’m at a loss.

The last bit of my code from the stacktrace above:

  defp reset_readstore do
    config = Application.get_env(:accounts, Accounts.Repo)
    {:ok, conn} = Postgrex.start_link(config)

    Postgrex.query!(conn, truncate_readstore_tables(), [])
  end

Most Liked

slashdotdash

slashdotdash

The GitHub repo for the “Building Conduit” eBook has been updated to use Commanded and EventStore v1.0 if you are still looking.

axelson

axelson

Scenic Core Team

Is there a particular reason you’re trying to cleanup the database tables yourself? The Ecto Sandbox is able to take of that for you (by running tests each in their own transaction, either sync or async). If you relied on the Sandbox to do the cleanup than you should be able to remove a bunch of your test configuration/setup.

gavares

gavares

Thanks @axelson, that’s really helpful. The cleanup code I have is taken from the commanded docs and I found similar code in the conduit repo that I am basing my app off of. If Sandbox can handle that logic for me, so much the better. I’ll give that a try.

gavares

gavares

@axelson, thanks for the help. Removing my manual cleanup code solved my problem.

LostKobrakai

LostKobrakai

EventStore doesn’t use ecto and therefore cannot be controlled using the ecto sandbox. It uses postgrex directly and therefore needs manual action for cleanup.

Where Next?

Popular in Questions Top

gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New

Other popular topics Top

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New

We're in Beta

About us Mission Statement