Changeset 3798
- Timestamp:
- 02/15/08 20:02:51 (17 months ago)
- Location:
- branches/0.10
- Files:
-
- 4 modified
-
lib/Doctrine/Export/Mysql.php (modified) (6 diffs)
-
lib/Doctrine/Sequence/Mysql.php (modified) (2 diffs)
-
lib/Doctrine/Table.php (modified) (2 diffs)
-
tests/Sequence/MysqlTestCase.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.10/lib/Doctrine/Export/Mysql.php
r3412 r3798 381 381 public function createSequence($sequenceName, $start = 1, array $options = array()) 382 382 { 383 $sequenceName = $this->conn->quoteIdentifier($ this->conn->getSequenceName($sequenceName), true);383 $sequenceName = $this->conn->quoteIdentifier($sequenceName, true); 384 384 $seqcolName = $this->conn->quoteIdentifier($this->conn->getAttribute(Doctrine::ATTR_SEQCOL_NAME), true); 385 385 … … 394 394 395 395 if (isset($options['collate'])) { 396 $optionsStrings['c ollate'] .= ' COLLATE ' . $options['collate'];396 $optionsStrings['charset'] .= ' COLLATE ' . $options['collate']; 397 397 } 398 398 } … … 403 403 $type = $options['type']; 404 404 } else { 405 $type = $this->conn-> default_table_type;405 $type = $this->conn->getAttribute(Doctrine::ATTR_DEFAULT_TABLE_TYPE); 406 406 } 407 407 if ($type) { … … 412 412 try { 413 413 $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, ' '); 418 416 419 417 $res = $this->conn->exec($query); … … 422 420 } 423 421 424 if ($start == 1 )422 if ($start == 1 && $res == 1) 425 423 return true; 426 424 … … 429 427 430 428 $res = $this->conn->exec($query); 429 430 if ($res == 1) 431 return true; 431 432 432 433 // Handle error -
branches/0.10/lib/Doctrine/Sequence/Mysql.php
r2963 r3798 43 43 public function nextId($seqName, $onDemand = true) 44 44 { 45 $sequenceName = $this->conn->quoteIdentifier($ this->conn->formatter->getSequenceName($seqName), true);45 $sequenceName = $this->conn->quoteIdentifier($seqName, true); 46 46 $seqcolName = $this->conn->quoteIdentifier($this->conn->getAttribute(Doctrine::ATTR_SEQCOL_NAME), true); 47 47 $query = 'INSERT INTO ' . $sequenceName . ' (' . $seqcolName . ') VALUES (NULL)'; … … 104 104 public function currId($seqName) 105 105 { 106 $sequenceName = $this->conn->quoteIdentifier($ this->conn->formatter->getSequenceName($seqName), true);106 $sequenceName = $this->conn->quoteIdentifier($seqName, true); 107 107 $seqcolName = $this->conn->quoteIdentifier($this->conn->getAttribute(Doctrine::ATTR_SEQCOL_NAME), true); 108 108 $query = 'SELECT MAX(' . $seqcolName . ') FROM ' . $sequenceName; -
branches/0.10/lib/Doctrine/Table.php
r3406 r3798 421 421 $found = true; 422 422 423 if ( $value) {423 if (is_string($value)) { 424 424 $this->_options['sequenceName'] = $value; 425 425 } else { … … 427 427 $this->_options['sequenceName'] = $sequence; 428 428 } else { 429 $this->_options['sequenceName'] = $this->_conn-> getSequenceName($this->_options['tableName']);429 $this->_options['sequenceName'] = $this->_conn->formatter->getSequenceName($this->_options['tableName']); 430 430 } 431 431 } -
branches/0.10/tests/Sequence/MysqlTestCase.php
r876 r3798 37 37 $this->sequence->currId('user'); 38 38 39 $this->assertEqual($this->adapter->pop(), 'SELECT MAX(id) FROM user _seq');39 $this->assertEqual($this->adapter->pop(), 'SELECT MAX(id) FROM user'); 40 40 } 41 41 public function testNextIdExecutesSql() … … 45 45 $this->assertEqual($id, 1); 46 46 47 $this->assertEqual($this->adapter->pop(), 'DELETE FROM user _seqWHERE id < 1');47 $this->assertEqual($this->adapter->pop(), 'DELETE FROM user WHERE id < 1'); 48 48 $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)'); 50 50 } 51 51 public function testLastInsertIdCallsPdoLevelEquivalent()