You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi 馃憢, and thanks for developing such a helpful project!
I'm wondering whether cardinality for optional lists is currently correctly defined as zero-or-one? I'm not very knowledgeable when it comes to ERDs, so this may be just wrong thinking on my side.
The following Pydantic model (two Child classes to avoid rendering issues) gives the ERD below, created by running erdantic my_module.Parent -d | dot -Tsvg > parent.svg. (pygraphviz 1.12)
I think the cardinality (0..*) at Child1 is correct: required_list is a list that can contain anything from zero to many instances of Child1.
However, the cardinality at Child2 (0..1) is wrong - I think? Following the logic derived from required_list (0..* instances of Child1can be included inrequired_list), I would expect the same cardinality at Child2 as well, meaning 0..* instances of Child2can be included inoptional_list (regardless of whether the list must exist, i.e., the field must be defined on instantiation).
I haven't had a look at the source code yet, but would assume that perhaps Optional fields are processed without looking at the type of the wrapped value?
Thanks, and do please correct me if I got it wrong.
The text was updated successfully, but these errors were encountered:
You are right. The current implementation of is_many only checks whether the outermost type is a container.
This actually surfaces a deeper issue, which is that our representation of manyness is wrong. Currently, it's set as a property of the field on the parent class, when it's really a property of the edge. For example, one field with the type annotation Union[Child1, List[Child2]] should be one-to-one with Child1 and one-to-many with Child2.
Hi 馃憢, and thanks for developing such a helpful project!
I'm wondering whether cardinality for optional lists is currently correctly defined as zero-or-one? I'm not very knowledgeable when it comes to ERDs, so this may be just wrong thinking on my side.
(This may be related to #90 as well.)
The following Pydantic model (two
Child
classes to avoid rendering issues) gives the ERD below, created by runningerdantic my_module.Parent -d | dot -Tsvg > parent.svg
. (pygraphviz 1.12
)I think the cardinality (
0..*
) atChild1
is correct:required_list
is a list that can contain anything from zero to many instances ofChild1
.However, the cardinality at
Child2
(0..1
) is wrong - I think? Following the logic derived fromrequired_list
(0..*
instances ofChild1
can be included inrequired_list
), I would expect the same cardinality atChild2
as well, meaning0..*
instances ofChild2
can be included inoptional_list
(regardless of whether the list must exist, i.e., the field must be defined on instantiation).I haven't had a look at the source code yet, but would assume that perhaps
Optional
fields are processed without looking at the type of the wrapped value?Thanks, and do please correct me if I got it wrong.
The text was updated successfully, but these errors were encountered: