Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fpYJm-0005z4-L6 for pgsql-general@arkaria.postgresql.org; Tue, 14 Aug 2018 12:20:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fpYJk-0004dC-RJ for pgsql-general@arkaria.postgresql.org; Tue, 14 Aug 2018 12:20:56 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fpYJh-0004GL-IF for pgsql-general@lists.postgresql.org; Tue, 14 Aug 2018 12:20:53 +0000 Received: from mail-pl0-x232.google.com ([2607:f8b0:400e:c01::232]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fpYJe-0000G0-Fr; Tue, 14 Aug 2018 12:20:51 +0000 Received: by mail-pl0-x232.google.com with SMTP id u11-v6so8251552plq.5; Tue, 14 Aug 2018 05:20:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=fdCfxKLL0Yd2KAdm3OiIRHRvZ0I7cx3Or5mprDiSJag=; b=k0o8JLtsY91Z0PW3sifMld5HCgAQFZhi906f/2outqSjiN3TXS1Gy91rpBmLdb0YO9 b5jvRwTgNnK0jIPxxwd7XWohTI6URa9IBeR/NPQ9/eWWDNDm5EpOWEBb35F7PuE+ZEF9 sSDbRpxzpJUOmAb0aowK2+Z8vWfPBO9sTl7VcknH+1dse+DZvYmXhcSdaQe/8Yy9rbow 3q3W/s7TgahC9uuth/gKpcoroCBIIa1qsxvZIDNQDc7jD1a5dCIRIOM0w/x8wxruVPr/ HxjakAhkOLtlQFoVKG7dromUj3+H1gwA/hNVZPibfC4vsGiooYSNUcCobS9Xsh3cLvIw KAzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=fdCfxKLL0Yd2KAdm3OiIRHRvZ0I7cx3Or5mprDiSJag=; b=cmSXeh3YFmCx5eYt0WmycHj1kCbcPq6eCCl/ewK05x9aJTVsnM2M5X4hp9dmmIgDo6 HZwAWojbFYks+2RpRlNQA0NFuZPtydt43IxOrygJs6RLZTIMTW9QOnbYJYjJXA23Ul0O oo4HpxoTIohNu/NOS1B0f4hMWGJTMCsKS4QYmRsZ0p/6A8tc2ug8qOiTQQpYLG+q8NxA je+zFBxEBGsQPctlthAwjOjKHEzteVbjS13sw5ldY4Z+VhE5HUfdng4XbCQE8Jl6SivY bpFDV7p77C7RJfuBpYxXVReEeRuqapW2VVveOnUDxU9rqQYdb0QErim1S9yTh3ZE3Kbn c1Dw== X-Gm-Message-State: AOUpUlEb4terhtNLC10Btz0FNLqYOq4xtEjugmTO+7/RFT07m8/int5a KEFA4+lQfAzPYk2Tu/s78tz8lNzI X-Google-Smtp-Source: AA+uWPyC798kawUNo7BJ7dZ2ZpDTIucJzez+97DR/VRpIQOAe1sxklGxzQGprt0MDxaDswUI7bbioQ== X-Received: by 2002:a17:902:b902:: with SMTP id bf2-v6mr19921521plb.160.1534249249444; Tue, 14 Aug 2018 05:20:49 -0700 (PDT) Received: from roblaptop ([220.240.104.230]) by smtp.gmail.com with ESMTPSA id 16-v6sm34660848pfo.164.2018.08.14.05.20.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Aug 2018 05:20:48 -0700 (PDT) Message-ID: <872466f8f89ce9c4ba3814095f5fed8c9aaaaa55.camel@gmail.com> Subject: Re: Uncaught PHP Exception Doctrine\DBAL\Exception\UniqueConstraintViolationException: "An exception occurred while executing 'UPDATE From: rob stone To: =?UTF-8?Q?Jaros=C5=82aw?= Torbicki , "pgsql-general@PostgreSQL.org" Cc: "scrappy@PostgreSQL.org" Date: Tue, 14 Aug 2018 22:20:44 +1000 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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