It seems to me the mistake is yours. If "it is perfectly legal for no
SubscriberUnitCoordinate to exist" then you can not define a foreign
key involving it. Defining a foreign key makes it required, even if
you set "required" to "false" in your schema.yml.


On Jul 16, 2:52 pm, Trevor Lanyon <[email protected]>
wrote:
> Hi,
>
> symfony propel:build-model builds this
>
> BaseSubscriberUnit.php:
>
> public function getSubscriberUnitCoordinate(PropelPDO $con = null)
> {
>     if ($this->aSubscriberUnitCoordinate === null &&
>         (($this->mac !== "" && $this->mac !== null) &&          
>          ($this->basestation_id !== "" &&
>           $this->basestation_id !== null))) {
>         $c = new Criteria(SubscriberUnitCoordinatePeer::DATABASE_NAME);
>         $c->add(SubscriberUnitCoordinatePeer::SUBSCRIBER_UNIT_MAC,
> $this->mac);
>         $c->add(SubscriberUnitCoordinatePeer::BASESTATION_ID,
> $this->basestation_id);
>         $this->aSubscriberUnitCoordinate =
> SubscriberUnitCoordinatePeer::doSelectOne($c, $con);
>          // Because this foreign key represents a one-to-one
> relationship, we will create a bi-directional association.
>         $this->aSubscriberUnitCoordinate->setSubscriberUnit($this);
>      }
>      return $this->aSubscriberUnitCoordinate;
>  }
>
> The problem is that it is perfectly legal for no
> SubscriberUnitCoordinate to exist and the program fails when it tries to
> assign any properties to an object that doesn't exist (ie: on this line
> '        $this->aSubscriberUnitCoordinate->setSubscriberUnit($this);').
>
> Is this a(nother) bug in propel?  Is there a work around?  Outside of
> either overriding the method in an inherited class or editing the basic
> class EVERYTIME I regenerate the model???
>
> Did I define my relationships  wrong?  Here's what my schema includes:
>
>  <table name="basestation" phpName="Basestation">
>    <column name="id" type="BIGINT" size="8" scale="0" primaryKey="true"
> required="true"/>
>    <index name="PK_basestation">
>      <index-column name="id"/>
>    </index>
>  </table>
>
>    <table name="subscriber_unit" phpName="SubscriberUnit">
>      <column name="basestation_id" type="BIGINT" size="8" scale="0"
> primaryKey="true" required="true"/>
>      <column name="mac" type="VARCHAR" size="32" primaryKey="true"
> required="true"/>
>      <column name="access_unit_slot" type="INTEGER" size="4" scale="0"
> required="true" defaultValue="((0))"/>
>      <foreign-key foreignTable="basestation"
> name="FK_subscriber_unit_basestation">
>        <reference local="basestation_id" foreign="id"/>
>      </foreign-key>
>      <foreign-key foreignTable="access_unit"
> name="FK_subscriber_unit_access_unit">
>        <reference local="basestation_id" foreign="basestation_id"/>
>        <reference local="access_unit_slot" foreign="slot"/>
>      </foreign-key>
>      <foreign-key foreignTable="subscriber_unit_coordinate"
> name="FK_subscriber_unit_subscriber_unit_coordinate">
>        <reference local="mac" foreign="subscriber_unit_mac"/>
>        <reference local="basestation_id" foreign="basestation_id"/>
>      </foreign-key>
>    </table>
>
>    <table name="subscriber_unit_coordinate"
> phpName="SubscriberUnitCoordinate">
>      <column name="basestation_id" type="BIGINT" size="8" scale="0"
> primaryKey="true" required="true"/>
>      <column name="subscriber_unit_mac" type="VARCHAR" size="32"
> primaryKey="true" required="true"/>
>      <foreign-key foreignTable="basestation"
> name="FK_subscriber_unit_coordinate_basestation">
>        <reference local="basestation_id" foreign="id"/>
>      </foreign-key>
>    </table>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to