From ff3a3ce3c86f5d7d6ceadbc586be4519d5e9cfaf Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 25 Sep 2003 01:32:08 +0000 Subject: [PATCH] fixed schema_proc to deal correct with empty ('') defaults --- phpgwapi/inc/class.schema_proc.inc.php | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/phpgwapi/inc/class.schema_proc.inc.php b/phpgwapi/inc/class.schema_proc.inc.php index 93981a847c..2b3e030d04 100644 --- a/phpgwapi/inc/class.schema_proc.inc.php +++ b/phpgwapi/inc/class.schema_proc.inc.php @@ -348,7 +348,6 @@ $sType = ''; $iPrecision = 0; $iScale = 0; - $sDefault = ''; $bNullable = true; reset($aField); @@ -365,35 +364,29 @@ case 'scale': $iScale = (int)$vAttrVal; break; - case 'default': - $sDefault = $vAttrVal; - if($DEBUG) { echo'
_GetFieldSQL(): Default="' . $sDefault . '"'; } - break; case 'nullable': $bNullable = $vAttrVal; break; + default: + break; } } // Translate the type for the DBMS if($sFieldSQL = $this->m_oTranslator->TranslateType($sType, $iPrecision, $iScale)) { - if($bNullable == False) + if(!$bNullable) { $sFieldSQL .= ' NOT NULL'; } - if($sDefault != '') + if(isset($aField['default'])) { - if($DEBUG) { echo'
_GetFieldSQL(): Calling TranslateDefault for "' . $sDefault . '"'; } + if($DEBUG) { echo'
_GetFieldSQL(): Calling TranslateDefault for "' . $aField['default'] . '"'; } // 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'"; } - elseif($sDefault == '0') - { - $sFieldSQL .= " DEFAULT '0'"; - } if($DEBUG) { echo'
_GetFieldSQL(): Outgoing SQL: ' . $sFieldSQL; } return true; }