0 votes


Since the new inheritance update for Propel models, my model starts to make unneccesary keys on all relations. (1:1, 1:m, m:m)

According to the Propel2 documentation on class table inheritance (link) you need to add a foreign key in order to delegate to that entity. The table itself also needs to have an identifier column.

Every time I make a relation to that delegated class, it will add two foreign keys instead of one. (both the identifier of the base as well as the delegated table). Now this wasn't a problem for so far since I just removed the unneccesary column generated and moved on. Except now I need to make a m:m relation, which does not allow me to remove that one unneccesary column.

Here is my situation, and where it goes wrong.


I'll be awaiting your reply, and thanks in advance.

in Solved by (150 points)
recategorized by

1 Answer

0 votes
Best answer

Hi. It's caused by redundant id field in User and Medewerker.

In case you're deriving Medewerker from User, you already had id from this entity. Try to remove id in Medewerker and it should work fine.

by Skipper developer (141k points)
selected by

That would be the case if this was a single table inheritance. Instead, it's a class table inheritance.

The properties of the derived class are stored in the base table (user), removing id from Medewerker would leave the actual table without a primary key.
Shadowing the Foreign key as PK/FK on Medewerker results in the same problem.

Copied from their documentation:

Class Table Inheritance uses one table per class in the inheritance structure; each table stores only the columns it doesn’t inherits from its parent. Propel doesn’t offer class table inheritance per se, however it provides a behavior called delegate, which offers the same functionality.
Again, delegation isn’t really inheritance. The Basketballer class doesn’t inherit from Player, but proxies method calls to Player. And since Propel uses __call() magic to achieve this proxying, an IDE won’t see the Player methods accessible to a Basketballer instance.

You can easily replicate the issue by importing the schema definition in the link on the main post (or find it at the propel2 documentation -> inheritance, section "class table inheritance"), then try to make a m:m relation between a newly created entity and footballer or basketballer.

Oh, ok. thanks for link and explanation. I thought that id is handled automatically by Propel also in this case.

I will check what we can do with this login in Skipper and let you know.

Can you please send me your real contact email to [email protected] so we can discuss testing of this update? thanks

I have sent it to you.

Please let me know if last updates works for you. Thanks!