Skip to content

Can't use isCrossRef with polymorphic relationships #1369

@lcsdms

Description

@lcsdms

When I try using the following schema to generate crossref methods for a polymorphic relationship, I get this error:
[Symfony\Component\Debug\Exception\FatalThrowableError] Call to a member function getPhpName() on null

  • Version used: 2.0.0-alpha7

This is the schema.xml for example:

<?xml version="1.0" encoding="utf-8"?>
<database name="default" defaultIdMethod="native" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="vendor/propel/propel/resources/xsd/database.xsd" defaultPhpNamingMethod="underscore">

  <table name="contact" idMethod="native" phpName="Contact">
    <column name="id" phpName="Id" type="INTEGER"  autoIncrement="true" primaryKey="true" required="true"/>
    <column name="name" phpName="Name" type="VARCHAR" size="45"/>
    <vendor type="mysql">
      <parameter name="Engine" value="InnoDB"/>
    </vendor>
  </table>

  <table name="entity_relationship" idMethod="native" isCrossRef="true" phpName="EntityRelationship">
    <column name="entity_id" phpName="EntityId" type="INTEGER" primaryKey="true" required="true"/>
    <column name="entity_type" phpName="EntityType" type="VARCHAR" size="45" />
    <!--Has to be primaryKey to generate getRelationships on model-->
    <column name="relationship_id" phpName="RelationshipId" type="INTEGER" primaryKey="true" required="true"/>
    <foreign-key foreignTable="contact">
      <reference local="entity_id" foreign="id"/>
      <reference local="entity_type" value="USER"/>
    </foreign-key>
    <foreign-key foreignTable="relationship" name="fk_entity_relationship_relationship">
      <reference local="relationship_id" foreign="id"/>
    </foreign-key>
    <index name="fk_entity_relationship_relationship_idx">
      <index-column name="relationship_id"/>
    </index>
    <vendor type="mysql">
      <parameter name="Engine" value="InnoDB"/>
    </vendor>
  </table>

  <table name="relationship" idMethod="native" phpName="Relationship">
    <column name="id" phpName="Id" type="INTEGER" primaryKey="true" required="true" autoIncrement="true"/>
    <column name="name" phpName="Name" type="VARCHAR" size="45"/>
    <column name="type" phpName="Type" type="VARCHAR" size="45"/>
    <vendor type="mysql">
      <parameter name="Engine" value="InnoDB"/>
    </vendor>
  </table>
</database>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions