BazingaFakerBundle icon indicating copy to clipboard operation
BazingaFakerBundle copied to clipboard

n:m table data population throw integrity constraint violation

Open lionelbzv opened this issue 10 years ago • 1 comments

Env = SF2.3 / Propel 1.6.9

schema.xml:

    <table name="follow" isCrossRef="true">
        <behavior name="timestampable" />
        <column name="user_id" type="integer" required="true" primaryKey="true" />
        <column name="debate_id" type="integer" required="true" primaryKey="true" />
        <foreign-key foreignTable="user" onDelete="CASCADE" onUpdate="CASCADE">
            <reference local="user_id" foreign="id" />
        </foreign-key>
        <foreign-key foreignTable="debate" onDelete="CASCADE" onUpdate="CASCADE">
            <reference local="debate_id" foreign="id" />
        </foreign-key>
    </table>

I've populated the 2 foreign tables without problem and want some random datas for the crossRef table:

        Acme\Model\Follow:
            number:                     150

The faker:populate try to populate this table with _sometimes_ the 2 same lines and for sure it throws the exception:

[PropelException]                                                                                                                                                     
  Unable to execute INSERT statement [INSERT INTO `follow` (`user_id`, `debate_id`, `created_at`, `updated_at`) VALUES (:p0, :p1, :p2, :p3)] [wrapped: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '73-136' for key 'PRIMARY']  

I've got the same problem with an "equal nest" table/relation.

Thanks.

lionelbzv avatar Mar 26 '14 10:03 lionelbzv

+1

c33s avatar Jun 05 '14 01:06 c33s