Propel2
Propel2 copied to clipboard
Wrong property used for auto_increment value
Hi,
When using an auto_increment field in an entity type (with idMethod native) with more than one primary key, the generated value (retrieved by lastInsertId) is saved into the wrong property.
In fact the auto_increment value is always saved in the first PK.
I created a short example. Here is my schema.xml
<?xml version="1.0" encoding="utf-8"?>
<database name="Test" defaultIdMethod="native" namespace="Test">
<table name="table2" idMethod="native" phpName="Table1">
<column name="pk1FK" phpName="IdentifyingFK" type="INTEGER" primaryKey="true" required="true"/>
<column name="pk2" phpName="AutoID" type="INTEGER" autoIncrement="true" primaryKey="true" required="true"/>
<column name="testcolumn" phpName="Test" type="VARCHAR" size="100" required="true"/>
<foreign-key foreignTable="table1" phpName="Table1" onDelete="CASCADE" onUpdate="CASCADE">
<reference local="pk1FK" foreign="pk1"/>
</foreign-key>
<vendor type="mysql">
<parameter name="Engine" value="InnoDB"/>
</vendor>
<behavior name="timestampable" />
</table>
<table name="table1" idMethod="native" phpName="Table2">
<column name="pk1" phpName="Pk" type="INTEGER" primaryKey="true" required="true"/>
<vendor type="mysql">
<parameter name="Engine" value="InnoDB"/>
</vendor>
<behavior name="timestampable" />
</table>
</database>
The bug is in the generated Table1.php on line 844 where the identifyingPK is set but not the AutoID primary key.

should actually be

Is someone able to make a PR here with suggested changes?