pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Uncaught PHP Exception Doctrine\DBAL\Exception\UniqueConstraintViolationException: "An exception occurred while executing 'UPDATE
2+ messages / 2 participants
[nested] [flat]

* Uncaught PHP Exception Doctrine\DBAL\Exception\UniqueConstraintViolationException: "An exception occurred while executing 'UPDATE
@ 2018-08-14 07:48 Jarosław Torbicki <jaroslaw.torbicki@symmetry.pl>
  2018-08-14 12:20 ` Re: Uncaught PHP Exception Doctrine\DBAL\Exception\UniqueConstraintViolationException: "An exception occurred while executing 'UPDATE rob stone <floriparob@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Jarosław Torbicki @ 2018-08-14 07:48 UTC (permalink / raw)
  To: pgsql-general; +Cc: scrappy@PostgreSQL.org <scrappy@PostgreSQL.org>

Hello,
I used PostgreSQL 9.3 but I executed upgrade few days ago.
Now, I am using 10.4 PostgreSQL and:
doctrine/annotations                 v1.2.7
doctrine/cache                       v1.4.2
doctrine/collections                 v1.3.0
doctrine/common                      v2.7.3
doctrine/dbal                        v2.5.13
doctrine/doctrine-bundle             v1.5.2
doctrine/doctrine-cache-bundle       v1.0.1
doctrine/inflector                   v1.0.1
doctrine/instantiator                1.0.5
doctrine/lexer                       v1.0.1
doctrine/orm                         v2.5.14


I have a problem with ManyToOne relation.
For example, I have main object with three child and when I execute on main object
                            $em = $this->getDoctrine()->getManager();
                            $em->merge($data);
                            $em->flush();
I sometimes get ERROR message like:
Uncaught PHP Exception Doctrine\DBAL\Exception\UniqueConstraintViolationException: "An exception occurred while executing 'UPDATE

I get this ERRROR message not for all main object and not for all child. For example, first update child object is ok but in second I get error.

SQL prepared by doctrine:
UPDATE child_table SET id = ?, name = ?, object_name = ?, object_size = ? WHERE id = ?' with params ["2", "test Name object 2", "test name object 2", "1234", 3]

In this sql the doctrine tries update object with id=3 using data from object with id = 2.

This problem didn't occur before executing upgrade to 10.4 version.

Can you help me and give some tips?


Pozdrawiam,
______________
Jarosław Torbicki
Analityk

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Uncaught PHP Exception Doctrine\DBAL\Exception\UniqueConstraintViolationException: "An exception occurred while executing 'UPDATE
  2018-08-14 07:48 Uncaught PHP Exception Doctrine\DBAL\Exception\UniqueConstraintViolationException: "An exception occurred while executing 'UPDATE Jarosław Torbicki <jaroslaw.torbicki@symmetry.pl>
@ 2018-08-14 12:20 ` rob stone <floriparob@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: rob stone @ 2018-08-14 12:20 UTC (permalink / raw)
  To: Jarosław Torbicki <jaroslaw.torbicki@symmetry.pl>; pgsql-general; +Cc: scrappy@PostgreSQL.org <scrappy@PostgreSQL.org>

Hello,

On Tue, 2018-08-14 at 07:48 +0000, Jarosław Torbicki wrote:
> Hello,                               
> I used PostgreSQL 9.3 but I executed upgrade few days ago.
> Now, I am using 10.4 PostgreSQL and:
> doctrine/annotations                 v1.2.7
> doctrine/cache                       v1.4.2  
> doctrine/collections                 v1.3.0
> doctrine/common                      v2.7.3
> doctrine/dbal                        v2.5.13
> doctrine/doctrine-bundle             v1.5.2 
> doctrine/doctrine-cache-bundle       v1.0.1
> doctrine/inflector                   v1.0.1
> doctrine/instantiator                1.0.5 
> doctrine/lexer                       v1.0.1 
> doctrine/orm                         v2.5.14
>  
>  
> I have a problem with ManyToOne relation.
> For example, I have main object with three child and when I execute
> on main object
>                             $em = $this->getDoctrine()->getManager();
>                             $em->merge($data);
>                             $em->flush();
> I sometimes get ERROR message like:
> Uncaught PHP Exception
> Doctrine\DBAL\Exception\UniqueConstraintViolationException: "An
> exception occurred while executing 'UPDATE
>  
> I get this ERRROR message not for all main object and not for all
> child. For example, first update child object is ok but in second I
> get error.
>  
> SQL prepared by doctrine:
> UPDATE child_table SET id = ?, name = ?, object_name = ?, object_size
> = ? WHERE id = ?' with params ["2", "test Name object 2", "test name
> object 2", "1234", 3]
>  
> In this sql the doctrine tries update object with id=3 using data
> from object with id = 2.
>  
> This problem didn’t occur before executing upgrade to 10.4 version.
>  
> Can you help me and give some tips?
>  
>  
> Pozdrawiam,
> ______________
> Jarosław Torbicki
> Analityk
>  


I haven't a clue what "doctrine" does but your update statement makes
no sense. It effectively is doing this based on your list of params:-

UPDATE child_table SET id = 2, name = 'test Name object 2', object_name
= 'test Name object 2', object_size = 1234 WHERE id = 3;

Why would you change the value of the id column?
If the column "id" is a primary key, you'll no doubt pull a constraint
violation.

Maybe altering your postgresl.conf file to log all statements you might
be able to follow the sequence of statements until the constraint
violation occurs and thus make the necessary changes to the "doctrine"
code.

HTH,
Rob 





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2018-08-14 12:20 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-08-14 07:48 Uncaught PHP Exception Doctrine\DBAL\Exception\UniqueConstraintViolationException: "An exception occurred while executing 'UPDATE Jarosław Torbicki <jaroslaw.torbicki@symmetry.pl>
2018-08-14 12:20 ` rob stone <floriparob@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox