@@ -30,7 +30,8 @@ defmodule Ecto.Repo do
3030 for more information. In spite of this, the following configuration values
3131 are common across all adapters:
3232
33- * `:name`- The name of the Repo supervisor process
33+ * `:name`- The name of the Repo supervisor process. Notice that
34+ it must be unique across **all repo modules**
3435
3536 * `:priv` - the directory where to keep repository data, like
3637 migrations, schema and more. Defaults to "priv/YOUR_REPO".
@@ -873,6 +874,21 @@ defmodule Ecto.Repo do
873874
874875 From this moment on, all future queries done by the current process will
875876 run on `:tenant_foo`.
877+
878+ > ### Global repo names {: .warning}
879+ >
880+ > The repo name resolution is global across all repo modules. When using
881+ > `put_dynamic_repo/1`, ensure you're referencing the intended repo, as
882+ > it is possible to accidentally reference repos from other modules:
883+ >
884+ > ```elixir
885+ > Repo.start_link(name: :primary)
886+ > AnalyticstRepo.start_link(name: :analytics)
887+ >
888+ > # This works but may not be intended - queries will use AnalyticsRepo's connection
889+ > Repo.put_dynamic_repo(:analytics)
890+ > Repo.all(User) # Executes against AnalyticsRepo's connection!
891+ > ```
876892 """
877893 @ doc group: "Process API"
878894 @ callback put_dynamic_repo ( name_or_pid :: atom ( ) | pid ( ) ) :: atom ( ) | pid ( )
0 commit comments