Ticket #62 (accepted defect)

Opened 5 years ago

Last modified 4 years ago

Elixir doesn't support relationships with several inverses (can happen with inheritance)

Reported by: guest Owned by: ged
Priority: minor Milestone: 0.8
Component: core Version: 0.6.0
Keywords: Cc:

Description

If we have base class A with a relation to class B, and a sub-class C, derived from A, C does not properly inherit the relation to B. There is some discussion of the issue here:

http://groups.google.com/group/sqlelixir/browse_thread/thread/314f25c71aec5d3a

Attachments

test_rel3.py (0.7 kB) - added by ged 4 years ago.
More complete test case. The "data" part is not coherent with the definition part (it was copy-pasted from another test) but the test fails before it reaches that point.

Change History

Changed 5 years ago by ged

  • owner set to ged
  • status changed from new to accepted

For the record, this is due to how the create_properties method automatically transform one prop to a backref, and assumes one particular relationship only ever has one inverse. This is not the case here. The thing is that I don't think you can set up backrefs sanely for this case (even manually), and if you don't have backrefs, you'll won't get the inverse relationships automatic update before flushing. If this is what you get automatically, that could be confusing, so I have to think of a way for the user to specify: "hey, I know this is going to give me a different behavior, but it is what I want to have, let me do it". Any idea what a good syntax for this would be?

Changed 5 years ago by ged

  • priority changed from normal to minor

Bumping to minor as there is an easy workaround.

Changed 5 years ago by ged

  • summary changed from Problem with Inheritence and Relationships to Elixir doesn't support relationships wtih several inverses (can happen with inheritance)

Changed 5 years ago by ged

  • summary changed from Elixir doesn't support relationships wtih several inverses (can happen with inheritance) to Elixir doesn't support relationships with several inverses (can happen with inheritance)

Changed 4 years ago by ged

For reference, this bug was reported by Paul Johnston (paj) and his models looked like this:

class PlanPart

plan = ManyToOne('Plan')

class PartA(PlanPart) class PartB(PlanPart) ... class Plan:

parta = OneToOne(PartA) partb = OneToOne(PartB)

Now, this didn't work. What did work is moving the ManyToOne relationship out of PlanPart and including it explicitly in PartA, PartB, etc.

Changed 4 years ago by ged

More complete test case. The "data" part is not coherent with the definition part (it was copy-pasted from another test) but the test fails before it reaches that point.

Changed 4 years ago by ged

  • milestone set to 0.8
Note: See TracTickets for help on using tickets.