Skip to content

Commit d2fdb20

Browse files
author
Leo B
committed
Improve docs, remove checked TODO
1 parent 114960f commit d2fdb20

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/ecto/schema.ex

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,20 @@ defmodule Ecto.Schema do
849849
end
850850
end
851851
852+
`has_many` can be defined over a foreign key that spans more than one column.
853+
854+
defmodule Domain do
855+
use Ecto.Schema
856+
857+
@primary_key false
858+
schema "domains" do
859+
field :tld, :string, primary_key: true
860+
field :name, :string, primary_key: true
861+
has_many :subdomains, Subdomain, foreign_key: [:parent_tld, :parent_name],
862+
references: [:tld, :name]
863+
end
864+
end
865+
852866
## Filtering associations
853867
854868
It is possible to specify a `:where` option that will filter the records
@@ -2091,7 +2105,6 @@ defmodule Ecto.Schema do
20912105
foreign_key_types when is_list(foreign_key_types) ->
20922106
foreign_key_types
20932107
foreign_key_type when is_atom(foreign_key_type) ->
2094-
# TODO add a test for this branch
20952108
List.duplicate(foreign_key_type, length(foreign_key_names))
20962109
end
20972110
foreign_key_types = Enum.map(foreign_key_types, &check_field_type!(mod, name, &1, opts))

0 commit comments

Comments
 (0)