Ticket #1044 (closed enhancement: fixed)

Opened 14 months ago

Last modified 13 months ago

Multiple relations of the same name

Reported by: jasoneisen Owned by: jwage
Priority: major Milestone: 0.11.0
Component: Schema Files Version: 0.11.0
Severity: Keywords:
Cc: Has Test: no
Status: Commit Approved Has Patch: no

Description

Doctrine should throw exceptions when multiple relations are given the same name. Currently only one of them is created. See attached.

Attachments

multiplerelations.php (0.9 KB) - added by jasoneisen 14 months ago.
inheritance.yml (1.7 KB) - added by thomas.s 13 months ago.
this changeset breaks column aggregation inheritance.

Change History

Changed 14 months ago by jasoneisen

  Changed 14 months ago by jwage

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

(In [4383]) fixes #1044

  Changed 14 months ago by jwage

  • milestone changed from 0.11.2 to 0.11.0

  Changed 13 months ago by thomas.s

  • status changed from closed to reopened
  • resolution fixed deleted

This changeset breaks my column aggregation inheritance. I have two inheritance trees, one for users (business client is a user, etc.) and one for profiles (business client profile is a profile, etc.). Each user type has a different profile type (business user has business user profile, etc.). When I have a user object, I want the attribute "Profile" to link to the correct profile. Therefore I gave each user the relation alias Profile, which links to the correct class (see attached schema-part).

All my tests run fine but after this changeset I get the error "A relationship with the name "Profile" already exists." when building the database.

Thomas

Changed 13 months ago by thomas.s

this changeset breaks column aggregation inheritance.

follow-up: ↓ 5   Changed 13 months ago by jwage

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

(In [4472]) fixes #1044 again - Added override option for relationship options to override the relation if it already exists

in reply to: ↑ 4   Changed 13 months ago by thomas.s

Replying to jwage:

(In [4472]) fixes #1044 again - Added override option for relationship options to override the relation if it already exists

Doesn't work for me, this is the var_dump of the $options-array, when the exception is thrown:

array(3) {
  ["local"]=>
  string(10) "profile_id"
  ["foreign"]=>
  string(2) "id"
  ["type"]=>
  int(0)
}

I added the override: true at multiple positions, no luck:

Profile:
  columns:
    id:
      type: integer(4)
      primary: true
      autoincrement: true
 [...cut...]
    # 1:1
    user_id:
      type: integer(4)
  relations:
    # 1:1
    User:
      class: sfGuardUser
      type: one
      foreignType: one
      local: user_id
      foreign: id
      override: true
  options:
    type: INNODB
    collate: utf8_unicode_ci
    charset: utf8
    override: true
ExpertProfile:
  inheritance:
    type: column_aggregation
    extends: PersonalProfile
    keyField: type
    keyValue: 2
  relations:
    # 1:1
    User:
      class: Expert
      foreignAlias: Profile
      type: one
      foreignType: one
      local: user_id
      foreign: id
      override: true
Client:
  inheritance:
    type: column_aggregation
    extends: sfGuardUser
    keyField: type
    keyValue: 1
  relations:
    Profile:
      override: true
  options:
    override: true

Where should I specify the override-option?

  Changed 13 months ago by jwage

  • status changed from closed to reopened
  • resolution fixed deleted

It would be very helpful if you could provide a failing test case, or a complete schema that I could build in symfony in order to reproduce the error. Preferably a test case :)

  Changed 13 months ago by jwage

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

(In [4502]) fixes #1044

  Changed 13 months ago by jwage

  • has_patch unset
  • mystatus set to Commit Approved
  • has_test unset

After some thought, I decided to revert this functionality. It is a unnecessary BC change for this point in Doctrine. We will change this behavior in 2.0 since things are a bit different with inheritance and everything else related. For 1.0, the functionality will remain that if a relation already exists with an alias, it will unset it and override it. In a previous revision it was changed to throw an exception, and started breaking your use case. So, I have changed it back now. Let me know if everything is good.

  Changed 13 months ago by thomas.s

Thanks Jon, works again as expected. I supplied no test case because I use PHPUnit for my tests and the doctrine test setup is a bit different. The doctrine test cases are on my to do list...

Note: See TracTickets for help on using tickets.