@@ -30,7 +30,8 @@ defmodule Ecto.Repo do
30
30
for more information. In spite of this, the following configuration values
31
31
are common across all adapters:
32
32
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**
34
35
35
36
* `:priv` - the directory where to keep repository data, like
36
37
migrations, schema and more. Defaults to "priv/YOUR_REPO".
@@ -873,6 +874,21 @@ defmodule Ecto.Repo do
873
874
874
875
From this moment on, all future queries done by the current process will
875
876
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
+ > ```
876
892
"""
877
893
@ doc group: "Process API"
878
894
@ callback put_dynamic_repo ( name_or_pid :: atom ( ) | pid ( ) ) :: atom ( ) | pid ( )
0 commit comments