Skip to content


Build crashes when no primaryKey on autoIncrement column #564

jonphipps opened this Issue · 1 comment

2 participants


In reverse engineering a MySql database, I discovered that there are apparently several tables in which there is an integer ID column that is autoIncrement but is not a primaryKey:

    <column name="id" phpName="Id" type="INTEGER" autoIncrement="true" required="true"/>

This causes quite a nice crash during a build in src/Propel/Generator/Builder/Om/ObjectBuilder.php->addDoInsertBodyRaw() on line 4839:


...since the table has an autoincrementing key, but the 'primaryKey' $column is null. It would seem that there should be a check somewhere before it crashes, either as a post-generation check on the reverse engineering, or a build preflight of the schema.xml file, or an exception thrown at the point of failure.

Simply ensuring that an autoIncrement column is also a primryKey column is the quick fix, once I figured out what was going on:

    <column name="id" phpName="Id" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
@marcj marcj added the Bug label
Propel member

Good catch. Feel free to submit a PR if you get to it before we do.

@marcj marcj added this to the alpha-3 milestone
@marcj marcj closed this in bfa4ac3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.