mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #4731 from tractorcow/pulls/3.2/fix-numeric-regeneration
BUG Prevent dev/build continually regenerating Number field type
This commit is contained in:
commit
46eaee5be1
@ -407,15 +407,17 @@ class MySQLSchemaManager extends DBSchemaManager {
|
||||
$precision = $values['precision'];
|
||||
}
|
||||
|
||||
$defaultValue = '';
|
||||
// Fix format of default value to match precision
|
||||
if (isset($values['default']) && is_numeric($values['default'])) {
|
||||
$decs = strpos($precision, ',') !== false
|
||||
? (int) substr($precision, strpos($precision, ',') + 1)
|
||||
: 0;
|
||||
$defaultValue = ' default ' . number_format($values['default'], $decs, '.', '');
|
||||
$values['default'] = number_format($values['default'], $decs, '.', '');
|
||||
} else {
|
||||
unset($values['default']);
|
||||
}
|
||||
|
||||
return "decimal($precision) not null $defaultValue";
|
||||
return "decimal($precision) not null" . $this->defaultClause($values);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -178,6 +178,11 @@ class DataObjectSchemaGenerationTest_DO extends DataObject implements TestOnly {
|
||||
private static $db = array(
|
||||
'Enum1' => 'Enum("A, B, C, D","")',
|
||||
'Enum2' => 'Enum("A, B, C, D","A")',
|
||||
'NumberField' => 'Decimal',
|
||||
'FloatingField' => 'Decimal(10,3,1.1)',
|
||||
'TextValue' => 'Varchar',
|
||||
'Date' => 'SS_Datetime',
|
||||
'MyNumber' => 'Int'
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user