I am using Propel to develop a system in which users can develop their own schemas, so am looking at some "edge cases". I have come across a schema that I think Propel should disallow, but it does seem to build. Can anyone suggest a use case for this?
<?xml version="1.0" encoding="UTF-8"?>
<database name="test" defaultIdMethod="native">
<table name="test_event">
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
<column name="name" type="varchar" size="50" required="true" />
<column name="description" type="varchar" size="250" />
<column name="location" type="varchar" size="250" />
<column name="nearest_city" type="varchar" size="100" />
<column name="organiser_id" type="integer" required="true" />
<!-- This FK is incomplete -->
<foreign-key foreignTable="test_organiser">
<reference local="organiser_id" foreign="id" />
</foreign-key>
</table>
<table name="test_organiser">
<!-- Has composite PK -->
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
<column name="secondary" type="integer" required="true" primaryKey="true" />
<column name="name" type="varchar" size="50" required="true" />
<column name="email" type="varchar" size="100" />
</table>
</database>
As you can see, the event table has an incomplete foreign reference to the organiser table. I'd have thought Propel would have detected that and kicked it out at build time - but apparently not! I can't see why this would be useful - the setTestOrganiser
and getTestOrganiser
methods in BaseTestEvent
only refer to one part of the composite PK (because, of course, the event side is only aware of the organiser_id part).
Propel 1.6.1, PHP 5.2.17.
No they're not useful. Propel does just not have a check for this use case at the moment. I've created a issue for it so you won't stumble over it again when we've implemented it.