Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2643

Problem on updating an entity with multi-column-identifier with Nullable field

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Can't Fix
    • Affects Version/s: 2.3
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:
    • Environment:
      Symfony 2.1.x, Doctrine 2.3.x-dev and MySQL 5.5.16

      Description

      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

        Activity

        Hide
        Benjamin Eberlei added a comment -

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

        Show
        Benjamin Eberlei added a comment - We cannot fix this issue, Doctrine needs the primary key columns to be a value not equaling NULL.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Dennis Jaschinski
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: