propelorm / Propel2

Propel2 is an open-source high-performance Object-Relational Mapping (ORM) for modern PHP
http://propelorm.org/
MIT License
1.26k stars 393 forks source link

Allow to use non-primary columns in crossref tables #1994

Closed vol4onok closed 3 months ago

vol4onok commented 3 months ago

Hi guys,

Not sure what was the reason for the change, but in Propel1 it was not mandatory to make the crossref table foreign keys also primary keys. It was handy when the crossref table relation had to be referenced further elsewhere.

I don't see any negative effects enabling this, but please correct me if I'm wrong.

Here is a pseudo-example:

<table name="user_group" isCrossRef="true">
  <column name="id" type="integer" primaryKey="true" required="true" />
  <column name="user_id" type="integer"/>
  <column name="group_id" type="integer"/>
  <foreign-key foreignTable="user">
    <reference local="user_id" foreign="id"/>
  </foreign-key>
  <foreign-key foreignTable="group">
    <reference local="group_id" foreign="id"/>
  </foreign-key>
</table>

<table name="user_group_logs">
    <column name="id"type="INTEGER" primaryKey="true" autoIncrement="true" required="true" />
    <column name="user_group_id" type="INTEGER" />
    <column name="log" type="VARCHAR" />
    <foreign-key foreignTable="user_group">
        <reference local="user_group_id" foreign="id" />
    </foreign-key>
</table>

https://github.com/propelorm/Propel2/pull/1559

PhilinTv commented 3 months ago

@vol4onok thanks for coming back to this long lasting PR!

  1. Could you please state what use-cases will be opened with this change?
  2. Please provide a relevant test(s) to cover this new use case.
vol4onok commented 3 months ago

@PhilinTv It was taken here https://github.com/propelorm/Propel2/pull/1559. I covered this improvement. I needed to understand what this fix does In tests everything is clear. This fix didn't work for example in desription. There are 2 cases. But it's an optional feature and can be released.

codecov-commenter commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 89.28%. Comparing base (1ca6543) to head (2f29c23). Report is 7 commits behind head on master.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1994 +/- ## ========================================= Coverage 89.28% 89.28% Complexity 8058 8058 ========================================= Files 232 232 Lines 24534 24534 ========================================= Hits 21905 21905 Misses 2629 2629 ``` | [Flag](https://app.codecov.io/gh/propelorm/Propel2/pull/1994/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=propelorm) | Coverage Δ | | |---|---|---| | [5-max](https://app.codecov.io/gh/propelorm/Propel2/pull/1994/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=propelorm) | `89.28% <100.00%> (ø)` | | | [7.4](https://app.codecov.io/gh/propelorm/Propel2/pull/1994/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=propelorm) | `89.28% <100.00%> (ø)` | | | [agnostic](https://app.codecov.io/gh/propelorm/Propel2/pull/1994/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=propelorm) | `68.57% <100.00%> (+1.12%)` | :arrow_up: | | [mysql](https://app.codecov.io/gh/propelorm/Propel2/pull/1994/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=propelorm) | `69.83% <100.00%> (ø)` | | | [pgsql](https://app.codecov.io/gh/propelorm/Propel2/pull/1994/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=propelorm) | `69.87% <100.00%> (ø)` | | | [sqlite](https://app.codecov.io/gh/propelorm/Propel2/pull/1994/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=propelorm) | `67.81% <100.00%> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=propelorm#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.