pcapel

pcapel

Giving a `nil` for `MyApp.Repo` configuration's `:pool` creates error

So, it seems like there is an issue where the value of the configuration for :pool in the Ecto configuration of a Phoenix application results in attempting to use nil as a module. You can minimally see this behavior by creating a new Phoenix application, setting the config :app_name, AppName.Repo, pool: nil and then attempting to create a simple migration.

I’m wondering if this is expected behavior and I’m just not understanding how to configure things correctly?

The issue I have with this is that I’d really prefer to manage all my configuration using Dotenvy and a runtime config. But because sending nil is treated as sending a value and doesn’t result in a default value being used, that breaks.

I can work around this by checking the environment and configuring things differently, but that feels pretty off to me. Is this just a thing to work around, or should I consider other approaches?

Most Liked

Exadra37

Exadra37

For anyone to be able to help you you need to provide the relevant parts of your config files where Ecto is being configured.

Also, prefer to past everything as text inside a code block, instead of using images.

joey_the_snake

joey_the_snake

Map.get actually knows the difference as well it’s just that the default value is nil unless otherwise specified. But both functions detect whether a key is present or not and act according to their specification. None of them treat nil as a missing key. For example:

iex(3)> Map.get(%{a: nil}, :a, "test")
nil

iex(4)> Map.get(%{a: nil}, :b, "test")
"test"
Exadra37

Exadra37

I also prefer to only use runtime.exs as much as possible, except for when it’s not possible.

I have proof of concept for a unrelated thing, but in the the docs you can read how I use runtime.exs:

https://github.com/Exadra37/elixir-phoenix-360-web-apps/blob/dev_runtime-wip/TRY_IT_OUT.md

Where Next?

Popular in Questions Top

Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
Kurisu
For example for a current url like http://localhost:4000/cosmetic/products?_utf8=✓&query=perfume&page=2, I would like to get: ...
New
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
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
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
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 I...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New

Other popular topics Top

malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
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
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New

We're in Beta

About us Mission Statement