Simple relation enhancement, bi-directional one-to-one relationships

Issue #1454 resolved
Former user created an issue

In cases where a bi-directional one-to-one relationship is required a simple enhancement could be made to automatically set uselist=False in some cases. If the referencing column (i.e. the one with the FK object passed in) is unique (either from a unique or primary constraint) then the nature of the relationship is easily deduced.

Comments (4)

  1. Mike Bayer repo owner

    im concerned it could lead to confusion due to its implicitness. i.e. "whats this uselist flag and why have i never had to use it before", when a column fails to reflect a unique constraint on a new backend, etc.

  2. Former user Account Deleted

    an extra paragraph/sentence or two in the relation tutorial and in the reference might be enough?

  3. Mike Bayer repo owner

    well no, because people don't read the documentation. its essentially a surprise behavior. The logic to determine many-to-one/one-to-many is quite involved, but if a foreign key is not detected, it fails loudly. this would be that same logic duplicated (since we need to ensure for multiple-column constraints, ensure that the join condition is simple, etc.) and it wouldn't work in many situations, failing silently. Its too much complexity and inconsistency for not enough benefit.

  4. Log in to comment