Development

#4247 (sfPropelData::loadDataFrom (Composite Primary Key with Foreign Key))

You must first sign up to be able to contribute.

Ticket #4247 (closed defect: fixed)

Opened 11 months ago

Last modified 10 months ago

sfPropelData::loadDataFrom (Composite Primary Key with Foreign Key)

Reported by: sapunou Assigned to: fabian
Priority: minor Milestone: 1.1.2
Component: other Version: 1.1.0
Keywords: Cc:
Qualification: Unreviewed

Description

load-data not correct working

schema.xml

<?xml version="1.0" encoding="UTF-8"?>
<database name="propel" defaultIdMethod="native" package="lib.model">
  <table name="client">
    <column name="id" type="INTEGER" required="true" primaryKey="true"/>
    <column name="name" type="VARCHAR" size="255"/>
  </table>
  <table name="folder">
    <column name="id" type="INTEGER" required="true" primaryKey="true"/>
    <column name="client_id" type="INTEGER" required="true" primaryKey="true" />
    <foreign-key foreignTable="client" onDelete="cascade">
       <reference local="client_id" foreign="id"/>
    </foreign-key>
    <column name="folder_id" type="INTEGER"/>
    <foreign-key foreignTable="folder" onDelete="cascade">
        <reference local="folder_id" foreign="id" />
    </foreign-key>
    <column name="name" type="VARCHAR" size="255" required="true" />
  </table>
</database>

data.yml

Client:
   C1:
      id:           0
      name:         Main
      
Folder:
   F1:
      id:           0
      client_id:    C1
      name:         Root
   F2:
      id:           1
      client_id:    C1
      folder_id:    F1
      name:         Child1
   F3:
      id:           2
      client_id:    C1
      folder_id:    F2
      name:         Child2
   F4:
      id:           3
      client_id:    C1
      folder_id:    F3
      name:         Child3

Folder: original results (folder_id not correct)

id      client_id  folder_id  name
----------------------------------
0       0          (Null)     Root
1       0          1          Child1
2       0          1          Child2
3       0          1          Child3

Folder: expected results

id      client_id  folder_id  name
----------------------------------
0       0          (Null)     Root
1       0          0          Child1
2       0          1          Child2
3       0          2          Child3

Solution in attachment.

Attachments

sfPropelData.class.php.diff (0.7 kB) - added by sapunou on 08/22/08 11:33:13.
Composite Primary Key with Foreign Key

Change History

08/22/08 11:33:13 changed by sapunou

  • attachment sfPropelData.class.php.diff added.

Composite Primary Key with Foreign Key

09/10/08 12:41:38 changed by mathgl

I have the same kind of issue and the patch is working great for me :) Thank you sapunou ! Can we expect the patch to be include soon in trunk and backport in 1.1 branch ?

09/17/08 19:36:55 changed by nicolas

  • status changed from new to closed.
  • resolution set to fixed.

(In [11618]) [1.1] fixed sfPropelData::loadDataFrom doesn't behave correctly with composite primary key (fixes #4247)

09/17/08 19:37:31 changed by nicolas

(In [11619]) [1.2] forthport r11618: fixed sfPropelData::loadDataFrom doesn't behave correctly with composite primary key (refs #4247)

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.