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

"Call to undefined method" in generated class for more than two foreign keys #1961

Open donholgo opened 1 year ago

donholgo commented 1 year ago

When generating classes for a schema with more than two foreign keys, not all methods are created.

This can be reproduced with the example from the "More than two foreign keys" section in the documentation: After creating the example schema

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

and running propel model:build, the generated Base/User.php contains calls

return $this->createGroupsQuery($type, $criteria)->find($con);

(in getGroups and countGroups), but there is no method createGroupsQuery defined. Same for createUsersQuery in Base/Group.php and Base/Type.php.

donholgo commented 1 year ago

This seems to have been a problem in Propel 1 already: https://github.com/propelorm/Propel/issues/1019