Ticket #835 (closed defect: fixed)

Opened 16 months ago

Last modified 16 months ago

sfDoctrine schema generates double model entries with Equal nest relations

Reported by: slickrick Owned by: jwage
Priority: minor Milestone: 0.10.3
Component: sfDoctrinePlugin Version: 0.10.0
Severity: Keywords:
Cc: Has Test:
Status: Has Patch:

Description

Here is a sample of my schema:

client.yml

Client: 
  tableName: client
  className: Client
  columns: 
    id: 
      notnull: true
      primary: true
      autoincrement: true
      type: integer
      length: 11
  relations:
    Client:
      refClass: ClientAffiliateGroup
      local: client_id
      foreign: affiliate_id
      foreignAlias: Affiliates
      equal: true

client_affiliate_group.yml

ClientAffiliateGroup:
  tableName: client_affiliate_group
  className: ClientAffiliateGroup
  columns: 
    client_id: 
      default: 
      notnull: true
      primary: true
      type: integer
      length: 11
      name: client_id
    affiliate_id: 
      default: 
      notnull: true
      primary: true
      type: integer
      length: 11
      name: affiliate_id

However, when my BaseClient?.php is generated, the setUp() looks like this:

public function setUp()
{
  $this->hasMany('Client', array('refClass' => 'ClientAffiliateGroup',
                                 'local' => 'client_id',
                                 'foreign' => 'affiliate_id',
                                 'equal' => true));

  $this->hasMany('Client as Affiliates', array('refClass' => 'ClientAffiliateGroup',
                                               'local' => 'affiliate_id',
                                               'foreign' => 'client_id'));
}

This could be user error. However, it's duplicating the Client entry, which is causing an issue because when you try to get Client->Affiliates, it brings back the wrong results because its treating affiliate_id as the local id.

Change History

Changed 16 months ago by jwage

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

Your schema is incorrect. I am pretty sure it should be this. I did a quick test and this works as expected.

  relations:
    Affiliates:
      class: Client
      refClass: ClientAffiliateGroup
      local: client_id
      foreign: affiliate_id
      foreignAlias: Clients

Changed 16 months ago by jwage

  • status changed from closed to reopened
  • resolution fixed deleted

Changed 16 months ago by jwage

  • status changed from reopened to closed
  • resolution set to invalid

Changed 16 months ago by jwage

  • status changed from closed to reopened
  • resolution invalid deleted
  • milestone changed from 0.10.4 to 0.10.3

We need to make one change to this. When equal => true on a relationship, it is not required to inflect the relationship and auto create the opposite end of the relationship.

Changed 16 months ago by jwage

  • status changed from reopened to closed
  • resolution set to fixed

(In [3966]) fixes #835

Note: See TracTickets for help on using tickets.