Doctrine 1
  1. Doctrine 1
  2. DC-113

The nextId method doesn't have a good path for non-existing sequences when autocreate is not enabled.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2.0-ALPHA2
    • Fix Version/s: 1.2.0-ALPHA3
    • Component/s: Geographical
    • Labels:
      None

      Description

      With the current code, the return data is outside the method's documentation for @return and there will be a notice from PHP about $result being undefined.

      Fixed with the following patch.

          public function nextId($seqName, $onDemand = true)
          {
              $sequenceName = $this->conn->quoteIdentifier($this->conn->formatter->getSequenceName($seqName), true);
      
              $query = "SELECT NEXTVAL('" . $sequenceName . "')";
              try {
                  $result = (int) $this->conn->fetchOne($query);
              } catch(Doctrine_Connection_Exception $e) {
                  if ($onDemand && $e->getPortableCode() == Doctrine::ERR_NOSUCHTABLE) {
      
                      try {
                          $result = $this->conn->export->createSequence($seqName);
                      } catch(Doctrine_Exception $e) {
                          throw new Doctrine_Sequence_Exception('on demand sequence ' . $seqName . ' could not be created');
                      }
                      return $this->nextId($seqName, false);
      +           } else {
      +             throw new Doctrine_Sequence_Exception('sequence ' .$seqName . ' does not exist');
                  }
              }
              return $result;
          }
      

        Activity

        Hide
        Guilherme Blanco added a comment -

        Issue fixed for 1.2 =)

        Show
        Guilherme Blanco added a comment - Issue fixed for 1.2 =)

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Maurice Makaay
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: