ash-project / ash_postgres

The PostgreSQL data layer for Ash Framework
https://hexdocs.pm/ash_postgres
MIT License
139 stars 73 forks source link

`configure_runtime/3` runs on repeat installs #356

Closed ibarakaiev closed 3 months ago

ibarakaiev commented 3 months ago

Describe the bug When mix igniter.install ash_postgres is run twice, configure_runtime/3 always keeps adding

if config_env() == :prod do
  ...
end

to runtime.exs. This bug surfaced after the recent change in Igniter: https://github.com/ash-project/igniter/pull/54; specifically, the PR ensured that Igniter.Code.Function.argument_matches_predicate?/3 never returns :error because it can mistakenly be interpreted as truthy in if calls, which is what happened here.

To Reproduce Run mix igniter.install ash_postgres twice with the most recent Igniter.

Expected behavior It only adds it once and not when it is already set.

Additional context Just tried using a pre-change version of Igniter and adding a dbg() statement to line 60 of the installer and it is indeed :error on repeat installs. This is not critical because configs are deep merged anyway. So it doesn't actually "matter" if it repeats 100 times.

zachdaniel commented 3 months ago

ah, thanks I'll take a look now :)

zachdaniel commented 3 months ago

Fixed in main