Add join support for tables with PK different than "id"#1077
Add join support for tables with PK different than "id"#1077
Conversation
|
What do you think about the naming and description of this, because that 'idField' is for the FakeModel, not the table itself : Lines 89 to 93 in 2426c4d i decided to make it nullable because in method |
|
Does this PR really solve #803? The issue describes something else, this PR adds support for PK to be different than "id". But if PK is "id" and we join based on a different column, the foreign model still needs to have the knowledge about PK to be "id", for AI (autoincrement) to work at least (not mentioning fake model will never execute proper model hooks). |
You are right about the hooks, it is a FakeModel so the only functionality of this PR is to build a correct query to avoid raising a DSQL Exception when an update on joined fields occurs, but no hook will be triggered. So join can be done directly with models? ( like this |
|
that is the direction, see #960, however Join class still relies on many hooks as we must hold a reference to joined data and that has limitations currently, imagine like same entity joined/referenced back in one model |
Ok, I will do some tests. |
|
in another repo I solved it in this way: Define a different Join Model::$_defaultSeedJoin Extend Join class Use it in this way: It works. |
There was a problem hiding this comment.
The src changes LGTM.
Here is a summary of the discussion above:
- #1077 (comment) - no fake model must be used for saving, this needs to reviewed before merge
- #1077 (comment) - in this PR, we probably do not want to do more, but tests need to pass with every DB engine - UPDATE: fixed by #1117
#1077 (comment) - @abbadon1334 what usecases does it solve vs. this PR? Some short example?
7836b65 to
7b4d41c
Compare
e4e47a0 to
d3933ca
Compare
cf347c7 to
6a5817f
Compare
|
Thank you, @abbadon1334, for this contribution and sorry for letting you wait almost a year. Fixing the DBAL issues needed for proper FK creation - #1117 - was not easy. |
related with #803