Skip to content
Permalink
Browse files

Removing length() from DboMysqli, fixes incorrect float length parsing.

Test case added.
  • Loading branch information...
markstory committed Oct 24, 2009
1 parent c6999ae commit 14bd47842ca767571596a1be159356dd8f66fb60
@@ -298,25 +298,6 @@ function column($real) {
}
return 'text';
}
/**
* Gets the length of a database-native column description, or null if no length
*
* @param string $real Real database-layer column type (i.e. "varchar(255)")
* @return integer An integer representing the length of the column
*/
function length($real) {
$col = str_replace(array(')', 'unsigned'), '', $real);
$limit = null;
if (strpos($col, '(') !== false) {
list($col, $limit) = explode('(', $col);
}
if ($limit != null) {
return intval($limit);
}
return null;
}
/**
* Enter description here...
*
@@ -154,6 +154,7 @@ function schema() {
* @subpackage cake.tests.cases.libs.model.datasources.dbo
*/
class DboMysqliTest extends CakeTestCase {
var $fixtures = array('core.datatype');
/**
* The Dbo instance to be tested
*
@@ -176,8 +177,6 @@ function skip() {
* @access public
*/
function setUp() {
$db = ConnectionManager::getDataSource('test_suite');
$this->db = new DboMysqliTestDb($db->config);
$this->model = new MysqliTestModel();
}
/**
@@ -186,7 +185,8 @@ function setUp() {
* @access public
*/
function tearDown() {
unset($this->db);
unset($this->model);
ClassRegistry::flush();
}
/**
* testIndexDetection method
@@ -195,7 +195,7 @@ function tearDown() {
* @access public
*/
function testIndexDetection() {
$this->db->cacheSources = $this->db->testing = false;
$this->db->cacheSources = false;
$name = $this->db->fullTableName('simple');
$this->db->query('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));');
@@ -298,12 +298,14 @@ function testColumn() {
$this->assertEqual($result, $expected);
}
/**
* undocumented function
* test mysqli transactions
*
* @return void
* @access public
*/
function testTransactions() {
$this->db->cacheSources = false;
$this->db->begin($this->model);
$this->assertTrue($this->db->_transactionStarted);
@@ -313,5 +315,15 @@ function testTransactions() {
$this->db->commit($this->model);
$this->assertFalse($this->db->_transactionStarted);
}
/**
* test that float values are correctly identified
*
* @return void
**/
function testFloatParsing() {
$model =& new Model(array('ds' => 'test_suite', 'table' => 'datatypes', 'name' => 'Datatype'));
$result = $this->db->describe($model);
$this->assertEqual((string)$result['float_field']['length'], '5,2');
}
}
?>

0 comments on commit 14bd478

Please sign in to comment.
You can’t perform that action at this time.