Changeset 3798

Show
Ignore:
Timestamp:
02/15/08 20:02:51 (17 months ago)
Author:
guilhermeblanco
Message:

Fixes #702 in 0.10 branch. Still misses trunk

Location:
branches/0.10
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • branches/0.10/lib/Doctrine/Export/Mysql.php

    r3412 r3798  
    381381    public function createSequence($sequenceName, $start = 1, array $options = array()) 
    382382    { 
    383         $sequenceName   = $this->conn->quoteIdentifier($this->conn->getSequenceName($sequenceName), true); 
     383        $sequenceName   = $this->conn->quoteIdentifier($sequenceName, true); 
    384384        $seqcolName     = $this->conn->quoteIdentifier($this->conn->getAttribute(Doctrine::ATTR_SEQCOL_NAME), true); 
    385385 
     
    394394 
    395395            if (isset($options['collate'])) { 
    396                 $optionsStrings['collate'] .= ' COLLATE ' . $options['collate']; 
     396                $optionsStrings['charset'] .= ' COLLATE ' . $options['collate']; 
    397397            } 
    398398        } 
     
    403403            $type = $options['type']; 
    404404        } else { 
    405             $type = $this->conn->default_table_type; 
     405            $type = $this->conn->getAttribute(Doctrine::ATTR_DEFAULT_TABLE_TYPE); 
    406406        } 
    407407        if ($type) { 
     
    412412        try { 
    413413            $query  = 'CREATE TABLE ' . $sequenceName 
    414                     . ' (' . $seqcolName . ' INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (' 
    415                     . $seqcolName . '))' 
    416                     . strlen($this->conn->default_table_type) ? ' TYPE = ' 
    417                     . $this->conn->default_table_type : ''; 
     414                    . ' (' . $seqcolName . ' BIGINT NOT NULL AUTO_INCREMENT, PRIMARY KEY (' 
     415                    . $seqcolName . ')) ' . implode($optionsStrings, ' '); 
    418416 
    419417            $res    = $this->conn->exec($query); 
     
    422420        } 
    423421 
    424         if ($start == 1) 
     422        if ($start == 1 && $res == 1) 
    425423            return true; 
    426424 
     
    429427 
    430428        $res    = $this->conn->exec($query); 
     429 
     430        if ($res == 1) 
     431            return true; 
    431432 
    432433        // Handle error 
  • branches/0.10/lib/Doctrine/Sequence/Mysql.php

    r2963 r3798  
    4343    public function nextId($seqName, $onDemand = true) 
    4444    { 
    45         $sequenceName  = $this->conn->quoteIdentifier($this->conn->formatter->getSequenceName($seqName), true); 
     45        $sequenceName  = $this->conn->quoteIdentifier($seqName, true); 
    4646        $seqcolName    = $this->conn->quoteIdentifier($this->conn->getAttribute(Doctrine::ATTR_SEQCOL_NAME), true); 
    4747        $query         = 'INSERT INTO ' . $sequenceName . ' (' . $seqcolName . ') VALUES (NULL)'; 
     
    104104    public function currId($seqName) 
    105105    { 
    106         $sequenceName   = $this->conn->quoteIdentifier($this->conn->formatter->getSequenceName($seqName), true); 
     106        $sequenceName   = $this->conn->quoteIdentifier($seqName, true); 
    107107        $seqcolName     = $this->conn->quoteIdentifier($this->conn->getAttribute(Doctrine::ATTR_SEQCOL_NAME), true); 
    108108        $query          = 'SELECT MAX(' . $seqcolName . ') FROM ' . $sequenceName; 
  • branches/0.10/lib/Doctrine/Table.php

    r3406 r3798  
    421421                                $found = true; 
    422422 
    423                                 if ($value) { 
     423                                if (is_string($value)) { 
    424424                                    $this->_options['sequenceName'] = $value; 
    425425                                } else { 
     
    427427                                        $this->_options['sequenceName'] = $sequence; 
    428428                                    } else { 
    429                                         $this->_options['sequenceName'] = $this->_conn->getSequenceName($this->_options['tableName']); 
     429                                        $this->_options['sequenceName'] = $this->_conn->formatter->getSequenceName($this->_options['tableName']); 
    430430                                    } 
    431431                                } 
  • branches/0.10/tests/Sequence/MysqlTestCase.php

    r876 r3798  
    3737        $this->sequence->currId('user'); 
    3838 
    39         $this->assertEqual($this->adapter->pop(), 'SELECT MAX(id) FROM user_seq'); 
     39        $this->assertEqual($this->adapter->pop(), 'SELECT MAX(id) FROM user'); 
    4040    } 
    4141    public function testNextIdExecutesSql()  
     
    4545        $this->assertEqual($id, 1); 
    4646 
    47         $this->assertEqual($this->adapter->pop(), 'DELETE FROM user_seq WHERE id < 1'); 
     47        $this->assertEqual($this->adapter->pop(), 'DELETE FROM user WHERE id < 1'); 
    4848        $this->assertEqual($this->adapter->pop(), 'LAST_INSERT_ID()'); 
    49         $this->assertEqual($this->adapter->pop(), 'INSERT INTO user_seq (id) VALUES (NULL)'); 
     49        $this->assertEqual($this->adapter->pop(), 'INSERT INTO user (id) VALUES (NULL)'); 
    5050    } 
    5151    public function testLastInsertIdCallsPdoLevelEquivalent()