DDC-2643: Problem on updating an entity with multi-column-identifier with Nullable field #3317

Closed
opened 2026-01-22 14:17:56 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Aug 30, 2013).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user hakayashii:

Updating an entity that has an multicolumn-key, where one or more columns can be null, would fail if one column is null. Following senario won't work:

CREATE TABLE t1 (
owner int(11) NOT NULL,
partner int(11) NOT NULL,
refNumber int(11) DEFAULT NULL,
text varchar(255) NOT NULL,
UNIQUE KEY refNumber (refNumber),
UNIQUE KEY identifier_key (owner,partner,refNumber)
);

$em = $this->getDoctrine()->getEntityManager();

$entity = $em->getRepository('CoreBundle:T1') ->findOneBy(array('owner'=>1,'partner'=>2)); // { Entity has following values 'owner':1,'partner':2, 'refNumber':null, 'text': "simple text"}
$entity->setText('another simple text');
$em->flush();
// results in following query: UPDATE t1 SET text = ? WHERE owner = ? AND partner = ? AND refNumber = ?
// the query resolves but doesn't change any, because "refNumber = null" should be "refNumber is null" to work

Originally created by @doctrinebot on GitHub (Aug 30, 2013). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user hakayashii: Updating an entity that has an multicolumn-key, where one or more columns can be null, would fail if one column is null. Following senario won't work: CREATE TABLE `t1` ( `owner` int(11) NOT NULL, `partner` int(11) NOT NULL, `refNumber` int(11) DEFAULT NULL, `text` varchar(255) NOT NULL, UNIQUE KEY `refNumber` (`refNumber`), UNIQUE KEY `identifier_key` (`owner`,`partner`,`refNumber`) ); $em = $this->getDoctrine()->getEntityManager(); $entity = $em->getRepository('CoreBundle:T1') ->findOneBy(array('owner'=>1,'partner'=>2)); // { Entity has following values 'owner':1,'partner':2, 'refNumber':null, 'text': "simple text"} $entity->setText('another simple text'); $em->flush(); // results in following query: UPDATE t1 SET text = ? WHERE owner = ? AND partner = ? AND refNumber = ? // the query resolves but doesn't change any, because "refNumber = null" should be "refNumber is null" to work
admin added the Bug label 2026-01-22 14:17:56 +01:00
admin closed this issue 2026-01-22 14:17:56 +01:00
Author
Owner

@doctrinebot commented on GitHub (Sep 8, 2013):

Comment created by @beberlei:

We cannot fix this issue, Doctrine needs the primary key columns to be a value not equaling NULL.

@doctrinebot commented on GitHub (Sep 8, 2013): Comment created by @beberlei: We cannot fix this issue, Doctrine needs the primary key columns to be a value not equaling NULL.
Author
Owner

@doctrinebot commented on GitHub (Sep 8, 2013):

Issue was closed with resolution "Can't Fix"

@doctrinebot commented on GitHub (Sep 8, 2013): Issue was closed with resolution "Can't Fix"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3317