API CHANGE: Change the way that Database::requireField() gets field type information from the underlying database driver. (from r82793)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@89708 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2009-10-21 02:15:29 +00:00
parent b07e4e5181
commit b117becef5

View File

@ -406,13 +406,13 @@ abstract class Database {
//on how they are structured. This needs to be tidied up. //on how they are structured. This needs to be tidied up.
$fieldValue = null; $fieldValue = null;
$newTable = false; $newTable = false;
Profiler::mark('requireField'); Profiler::mark('requireField');
// backwards compatibility patch for pre 2.4 requireField() calls // backwards compatibility patch for pre 2.4 requireField() calls
$spec_orig=$spec; $spec_orig=$spec;
if(!is_string($spec)) { if(!is_string($spec)) {
// TODO: This is tempororary
$spec['parts']['name'] = $field; $spec['parts']['name'] = $field;
$spec_orig['parts']['name'] = $field; $spec_orig['parts']['name'] = $field;
//Convert the $spec array into a database-specific string //Convert the $spec array into a database-specific string
@ -431,13 +431,12 @@ abstract class Database {
if(!$newTable && !isset($this->fieldList[$table])) { if(!$newTable && !isset($this->fieldList[$table])) {
$this->fieldList[$table] = $this->fieldList($table); $this->fieldList[$table] = $this->fieldList($table);
} }
// Get the value of this field. if(is_array($spec)) {
if(is_array($spec)){ $specValue = DB::getConn()->$spec_orig['type']($spec_orig['parts']);
$specValue=$spec['data_type']; } else {
if(isset($spec['precision'])) $specValue = $spec;
$specValue.='(' . $spec['precision'] . ')'; }
} else $specValue=$spec;
// We need to get db-specific versions of the ID column: // We need to get db-specific versions of the ID column:
if($spec_orig==DB::getConn()->IdColumn() || $spec_orig==DB::getConn()->IdColumn(true)) if($spec_orig==DB::getConn()->IdColumn() || $spec_orig==DB::getConn()->IdColumn(true))
@ -500,7 +499,7 @@ abstract class Database {
Profiler::mark('alterField'); Profiler::mark('alterField');
$this->transAlterField($table, $field, $spec_orig); $this->transAlterField($table, $field, $spec_orig);
Profiler::unmark('alterField'); Profiler::unmark('alterField');
Database::alteration_message("Field $table.$field: changed to $spec_orig <i style=\"color: #AAA\">(from {$fieldValue})</i>","changed"); Database::alteration_message("Field $table.$field: changed to $specValue <i style=\"color: #AAA\">(from {$fieldValue})</i>","changed");
} }
Profiler::unmark('requireField'); Profiler::unmark('requireField');
} }
@ -892,4 +891,4 @@ abstract class Query implements Iterator {
abstract function seek($rowNum); abstract function seek($rowNum);
} }
?> ?>