1784 - Fix Toolkit error on decimals

This commit is contained in:
Eric
2018-11-21 15:11:19 +01:00
parent 12d9551845
commit 0a3f076335

View File

@@ -900,6 +900,20 @@ class CMDBSource
return ($aFieldData["Type"]);
}
private static function IsNumericType($aFieldData)
{
$aNumericTypes = array('tinyint(', 'decimal(', 'int(' );
$sType = strtolower($aFieldData["Type"]);
foreach ($aNumericTypes as $sNumericType)
{
if (strpos($sType, $sNumericType) === 0)
{
return true;
}
}
return false;
}
/**
* @param string $sTable
* @param string $sField
@@ -938,8 +952,15 @@ class CMDBSource
}
else
{
$default = $aFieldData["Default"] + 0; // Coerce to a numeric variable
$sRet .= ' DEFAULT '.self::Quote($default);
if (self::IsNumericType($aFieldData))
{
$sRet .= ' DEFAULT '.$aFieldData["Default"];
}
else
{
$default = $aFieldData["Default"] + 0; // Coerce to a numeric variable
$sRet .= ' DEFAULT '.self::Quote($default);
}
}
}
elseif (is_string($aFieldData["Default"]) == 'string')