fixed schema_proc to deal correct with empty ('') defaults

This commit is contained in:
Ralf Becker 2003-09-25 01:32:08 +00:00
parent f9206f08f7
commit ff3a3ce3c8

View File

@ -348,7 +348,6 @@
$sType = ''; $sType = '';
$iPrecision = 0; $iPrecision = 0;
$iScale = 0; $iScale = 0;
$sDefault = '';
$bNullable = true; $bNullable = true;
reset($aField); reset($aField);
@ -365,35 +364,29 @@
case 'scale': case 'scale':
$iScale = (int)$vAttrVal; $iScale = (int)$vAttrVal;
break; break;
case 'default':
$sDefault = $vAttrVal;
if($DEBUG) { echo'<br>_GetFieldSQL(): Default="' . $sDefault . '"'; }
break;
case 'nullable': case 'nullable':
$bNullable = $vAttrVal; $bNullable = $vAttrVal;
break; break;
default:
break;
} }
} }
// Translate the type for the DBMS // Translate the type for the DBMS
if($sFieldSQL = $this->m_oTranslator->TranslateType($sType, $iPrecision, $iScale)) if($sFieldSQL = $this->m_oTranslator->TranslateType($sType, $iPrecision, $iScale))
{ {
if($bNullable == False) if(!$bNullable)
{ {
$sFieldSQL .= ' NOT NULL'; $sFieldSQL .= ' NOT NULL';
} }
if($sDefault != '') if(isset($aField['default']))
{ {
if($DEBUG) { echo'<br>_GetFieldSQL(): Calling TranslateDefault for "' . $sDefault . '"'; } if($DEBUG) { echo'<br>_GetFieldSQL(): Calling TranslateDefault for "' . $aField['default'] . '"'; }
// Get default DDL - useful for differences in date defaults (eg, now() vs. getdate()) // Get default DDL - useful for differences in date defaults (eg, now() vs. getdate())
$sTranslatedDefault = $this->m_oTranslator->TranslateDefault($sDefault); $sTranslatedDefault = $aField['default'] == '0' ? $aField['default'] : $this->m_oTranslator->TranslateDefault($aField['default']);
$sFieldSQL .= " DEFAULT '$sTranslatedDefault'"; $sFieldSQL .= " DEFAULT '$sTranslatedDefault'";
} }
elseif($sDefault == '0')
{
$sFieldSQL .= " DEFAULT '0'";
}
if($DEBUG) { echo'<br>_GetFieldSQL(): Outgoing SQL: ' . $sFieldSQL; } if($DEBUG) { echo'<br>_GetFieldSQL(): Outgoing SQL: ' . $sFieldSQL; }
return true; return true;
} }