Project

General

Profile

Bug #20346 ยป 10965.diff

Administrator Admin, 2009-11-09 19:28

View differences:

class.ux_t3lib_db.php (working copy)
// Add slashes old-school:
// cast numerical values
$mt = $this->sql_field_metatype($table, $k);
$v = (($mt{0} == 'I') || ($mt{0} == 'F')) ? (int)$v : $v;
if ($mt{0} == 'I') {
$v = (int)$v;
} else if ($mt{0} == 'F') {
$v = (double)$v;
}
$nArr[$this->quoteFieldNames($k)] = (!in_array($k,$no_quote_fields)) ? $this->fullQuoteStr($v, $table) : $v;
}
......
// Add slashes old-school:
// cast numeric values
$mt = $this->sql_field_metatype($table, $k);
$v = (($mt{0} == 'I') || ($mt{0} == 'F')) ? (int)$v : $v;
if ($mt{0} == 'I') {
$v = (int)$v;
} else if ($mt{0} == 'F') {
$v = (double)$v;
}
$nArr[] = $this->quoteFieldNames($k) . '=' . ((!in_array($k, $no_quote_fields)) ? $this->fullQuoteStr($v, $table) : $v);
}
}
tests/db_general_testcase.php (working copy)
$expected .= ' AND sys_refindex.ref_string LIKE CONCAT(tx_dam_file_tracking.file_path,tx_dam_file_tracking.file_name)';
$this->assertEquals($expected, $query);
}
/**
* @test
* @see http://bugs.typo3.org/view.php?id=10965
*/
public function floatNumberCanBeStoredInDatabase() {
// Prepare a fake extension configuration
$ext_tables = t3lib_div::tempnam('ext_tables');
t3lib_div::writeFile($ext_tables, '
CREATE TABLE tx_test_dbal (
foo double default \'0\',
foobar integer default \'0\'
);
');
$GLOBALS['TYPO3_LOADED_EXT']['test_dbal'] = array(
'ext_tables.sql' => $ext_tables
);
// Append our test table to the list of existing tables
$this->fixture->clearCachedFieldInfo();
$this->fixture->_call('initInternalVariables');
$data = array(
'foo' => 99.12,
'foobar' => -120,
);
$query = $this->cleanSql($this->fixture->INSERTquery('tx_test_dbal', $data));
$expected = 'INSERT INTO tx_test_dbal ( foo, foobar ) VALUES ( \'99.12\', \'-120\' )';
$this->assertEquals($expected, $query);
// Remove temporary file
unlink($ext_tables);
}
}
?>
    (1-1/1)