Sleepful
So I was reading of the multiple modes for Ecto.Adapters.SQL.Sandbox, it seems you have to use only one of the modes for your test suite so you have to pick one of the three options available: :auto (default), :manual or :shared.
Trying to figure out which is the best, so I want to poll opinions ![]()
Found this related article which explains it a little more Making Sense of Ecto 2 SQL.Sandbox and Connection Ownership Modes
Trending in Discussions
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
New
Hey there,
It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Quite interesting article Google brought me. Didn’t find any mentions about it here.
What do you think in general? Would you use togethe...
New
It would be helpful to have a list of companies worldwide that hire engineers without prior experience in Elixir. Often, it can be quite ...
New
Anyone running long-lived stateful processes on BEAM? We’re building an AI agent runtime and would love to compare notes.
We’re a small ...
New
Other Trending Topics
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 4- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
JohnnyCurran
The links you shared are a little out of date
The updated documentation is at Ecto.Adapters.SQL.Sandbox — Ecto SQL v3.14.0 - Your version is Ecto 2.0 beta. Ecto is now on version 3.9
You probably want to leave it on
:autoor set it to:manual- I set it to:manualintest_helpers.exsIf you use
:shared, you can no longer run your tests async. This is because:sharedmode can introduce non-determinism because the test processes / transactions can see each of the other test transactions data it has inserted into the database. See 8 Common Causes of Flaky Tests in Elixir | AppSignal Blog for more info (#2 in the list)Sleepful
Oh you are right that I linked an older version of
ecto. Well it seems like the docs for Ecto.Adapters.SQL.Sandbox have not changed much between versions and it works the same, unless I missed some relevant difference. So the links I shared still remain relevant. Did notice one difference::automode in newer version does not requirecheckin/1to return connections to the pool.Yeah lets talk about this!
So there is
:autoand:manuallike you mention, they have the advantage of runningasync, then there is:sharedand it has the limitation of not allowingasynctests. These differences and nuances are covered in the article I shared so I won’t go over them.The point here is that running tests synchronously is the trade-off from using
:shared, but that does not mean that:sharedis less capable, it simply offers different advantages.For example, you can’t easily use
setup_all/1with:manualor:automodes. In:manualyou need to create an allowance for each test, whilst in:autoyou have to useon_exit/2callback to manually clean-up all of the changes on the database from yoursetup_all/1block.I suppose you don’t use
setup_allmuch so you have no need to worry about these issues?I don’t think it is easy to tell what people probably want without being nuanced with these topics.
Sleepful
So tell me about your experience with
:manualmode, any quirks that you have ran into? Do you have to write allowances often?Another of the tricky points with
:manualmode is that if your production code uses concurrent queries to the database, then you cannot write allowances for those processes from your test files.Sleepful
This makes me think of another question… Can you mix modes for different tests or is that bound to cause chaos?