Development

#5849 (Problem with Doctrine - Equal nest relations)

You must first sign up to be able to contribute.

Ticket #5849 (new defect)

Opened 6 years ago

Last modified 3 years ago

Problem with Doctrine - Equal nest relations

Reported by: nilky4ever Assigned to: Jonathan.Wage
Priority: major Milestone:
Component: sfDoctrinePlugin Version: 1.4.x DEV
Keywords: doctrine nest 1062 SQLSTATE[23000]: self-referencing duplicate key h2aEqualable Cc:
Qualification: Unreviewed

Description

Hi everyone!

Every time I try to update a record with its Friends give this error:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-1' for key 1

I've been debugging and when I edit a record and relate to 2 friends it performs 3 statements, 1 DELETE and 2 INSERT (each insert per each friend) but when I edit a record Friend it just try to perform 2 UPDATE.

Thanks in advance.

Change History

08/07/09 20:48:27 changed by cmartin

  • version changed from 1.2.4 to 1.2.8.

I've stumbled upon the same problem

I've built an equal nest relation with Doctrine. I can query the relation both ways as expected. I can edit all I want on way, but saving my objects from the other side of the relation gives me the same error message :

QLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-1' for key 1

I'm using symfony 1.2.8 so the bug is still present

08/10/09 16:17:45 changed by tbergeron

It would be awesome if someone could fix this bug as it's been a major annoyance for months.

And like everyone already said in the ticket, I'm also trying to do an equal nest relation with Doctrine, so the question would be: Is it Doctrine's fault? As symfony 1.2.8 is currently using Doctrine 1.1 and Doctrine is now 2 version ahead of the one symfony is using right now.

Thanks for your future help.

06/18/10 18:30:33 changed by pgueguin

  • keywords set to doctrine nest 1062 SQLSTATE[23000]:.
  • version changed from 1.2.8 to 1.4.5.

I got the same problem with non-equal nest relations SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '87-87' for key 'PRIMARY'

It looks like a doctrine bug from the query look which makes no sense: execute : UPDATE cop_job_stream_successor SET job_stream_destination_id = ?, updated_at = ? WHERE job_stream_source_id = ? AND job_stream_destination_id = ? - (87, 2010-06-18 18:24:20, 87, 94)

06/30/10 11:14:05 changed by nev3rm0re

I get the same error when trying to save existing relation.

Query that gives problems is: UPDATE similar_product SET line2 = '4' WHERE line1 = '4' AND line2 = '3'

Have no idea why it tries to make 3-4 relation into 4-4

01/11/11 20:41:37 changed by Mak84

I had the same problem and the solution is here: http://www.doctrine-project.org/jira/browse/DC-329

IMHO this is a Doctrine bug when handling equal nest relationships, this happened to me using the admin generator.

The link has a solution installing a really simple Doctrine extension. I'm still testing it, but it seems to work OK.

01/26/11 12:27:21 changed by BigBadBassMan

  • keywords changed from doctrine nest 1062 SQLSTATE[23000]: to doctrine nest 1062 SQLSTATE[23000]: self-referencing duplicate key h2aEqualable.
  • version changed from 1.4.5 to 1.4.x DEV.

still present in 1.4.9-dev but workaround proposed in http://www.doctrine-project.org/jira/browse/DC-329 does not work completely:

child-relations are still deleted, only false update of relations of the childs is prevented by the doctrine extension h2aEqualable.

01/26/11 12:41:42 changed by BigBadBassMan

  • owner changed from fabien to Jonathan.Wage.
  • component changed from model to sfDoctrinePlugin.

06/07/11 13:16:14 changed by BigBadBassMan

fixed for *Non-Equal* Nest Relations by using refClassRelationAlias: Schema option. see http://www.doctrine-project.org/jira/browse/DC-329.