/** * @see DBManager::oneColumnSQLRep() */ protected function oneColumnSQLRep($fieldDef, $ignoreRequired = false, $table = '', $return_as_array = false) { if (!empty($fieldDef['len'])) { // Variable-length can be a value from 1 through 8,000 or 4,000 for (n). // Max indicates that the maximum storage size is 2^31-1 bytes. // The storage size is the actual length of data entered + 2 bytes. // @link: http://msdn.microsoft.com/en-us/library/ff848814.aspx $colType = $this->getColumnType($this->getFieldType($fieldDef)); if ($parts = $this->getTypeParts($colType)) { $colType = $parts['baseType']; } switch (strtolower($colType)) { case 'char': case 'binary': if (8000 < $fieldDef['len']) { $fieldDef['len'] = 8000; } break; case 'varchar': case 'varbinary': if (8000 < $fieldDef['len']) { $fieldDef['len'] = 'max'; } break; case 'nchar': if (4000 < $fieldDef['len']) { $fieldDef['len'] = 4000; } break; case 'nvarchar': if (4000 < $fieldDef['len']) { $fieldDef['len'] = 'max'; } break; } } //Bug 25814 if (isset($fieldDef['name'])) { $colType = $this->getFieldType($fieldDef); if (stristr($this->getFieldType($fieldDef), 'decimal') && isset($fieldDef['len'])) { $fieldDef['len'] = min($fieldDef['len'], 38); } //bug: 39690 float(8) is interpreted as real and this generates a diff when doing repair if (stristr($colType, 'float') && isset($fieldDef['len']) && $fieldDef['len'] == 8) { unset($fieldDef['len']); } } // always return as array for post-processing $ref = parent::oneColumnSQLRep($fieldDef, $ignoreRequired, $table, true); // Bug 24307 - Don't add precision for float fields. if (stristr($ref['colType'], 'float')) { $ref['colType'] = preg_replace('/(,\\d+)/', '', $ref['colType']); } if ($return_as_array) { return $ref; } else { return "{$ref['name']} {$ref['colType']} {$ref['default']} {$ref['required']} {$ref['auto_increment']}"; } }
/** * @see DBManager::oneColumnSQLRep() */ protected function oneColumnSQLRep($fieldDef, $ignoreRequired = false, $table = '', $return_as_array = false) { // always return as array for post-processing $ref = parent::oneColumnSQLRep($fieldDef, $ignoreRequired, $table, true); if ($ref['colType'] == 'int' && !empty($fieldDef['len'])) { $ref['colType'] .= "(" . $fieldDef['len'] . ")"; } // bug 22338 - don't set a default value on text or blob fields if (isset($ref['default']) && in_array($ref['colBaseType'], array('text', 'blob', 'longtext', 'longblob'))) { $ref['default'] = ''; } if ($return_as_array) { return $ref; } else { return "{$ref['name']} {$ref['colType']} {$ref['default']} {$ref['required']} {$ref['auto_increment']}"; } }
protected function oneColumnSQLRep($fieldDef, $ignoreRequired = false, $table = '', $return_as_array = false) { if (isset($fieldDef['name'])) { if (stristr($this->getFieldType($fieldDef), 'decimal') && isset($fieldDef['len'])) { $fieldDef['len'] = min($fieldDef['len'], 31); // DB2 max precision is 31 for LUW, may be different for other OSs } } //May need to add primary key and sequence stuff here $ref = parent::oneColumnSQLRep($fieldDef, $ignoreRequired, $table, true); $matches = array(); if (!empty($fieldDef['len']) && preg_match('/^decimal(\\((?P<len>\\d*),*(?P<prec>\\d*)\\))?$/i', $ref['colType'], $matches)) { // Overriding len and precision for decimals as the current DBManager class doesn't handle decimal as both regular type and dbtype well // if(strpos($fieldDef['len'], ',') === false) // { // $numspec = array($fieldDef['len']); // We are ignoring the length if it existed since we have one that comes from the vardefs // $numspec []= !empty($fieldDef['precision']) ? $fieldDef['precision'] : $matches['prec']; // Use the vardef precision if it exists otherwise use the one that was already present // $ref['colType'] = 'decimal('.implode(',',$numspec).')'; // Reconstuct type based on new values // } else { $numspec = array($fieldDef['len']); // We are ignoring the length if it existed since we have one that comes from the vardefs if (!empty($fieldDef['precision']) && !strpos($fieldDef['len'], ',')) { $numspec[] = $fieldDef['precision']; } // Use the vardef precision if it exists and wasn't specified in the length $ref['colType'] = 'decimal(' . implode(',', $numspec) . ')'; // } } if (!empty($ref['default']) && in_array($ref['colBaseType'], array('integer', 'smallint', 'bigint', 'double', 'decimal'))) { $ref['default'] = str_replace(array("'", "\""), "", $ref['default']); // Stripping quotes } if ($return_as_array) { return $ref; } else { if ($ref['required'] == 'NULL') { // DB2 doesn't have NULL definition, only NOT NULL $ref['required'] = ''; // ONLY important when statement is rendered } return "{$ref['name']} {$ref['colType']} {$ref['default']} {$ref['required']} {$ref['auto_increment']}"; } }
/** * @see DBManager::oneColumnSQLRep() */ protected function oneColumnSQLRep($fieldDef, $ignoreRequired = false, $table = '', $return_as_array = false) { //Bug 25814 if (isset($fieldDef['name'])) { $colType = $this->getFieldType($fieldDef); if (stristr($this->getFieldType($fieldDef), 'decimal') && isset($fieldDef['len'])) { $fieldDef['len'] = min($fieldDef['len'], 38); } //bug: 39690 float(8) is interpreted as real and this generates a diff when doing repair if (stristr($colType, 'float') && isset($fieldDef['len']) && $fieldDef['len'] == 8) { unset($fieldDef['len']); } } // always return as array for post-processing $ref = parent::oneColumnSQLRep($fieldDef, $ignoreRequired, $table, true); // Bug 24307 - Don't add precision for float fields. if (stristr($ref['colType'], 'float')) { $ref['colType'] = preg_replace('/(,\\d+)/', '', $ref['colType']); } if ($return_as_array) { return $ref; } else { return "{$ref['name']} {$ref['colType']} {$ref['default']} {$ref['required']} {$ref['auto_increment']}"; } }
/** * @see DBManager::oneColumnSQLRep() */ protected function oneColumnSQLRep($fieldDef, $ignoreRequired = false, $table = '', $return_as_array = false) { //Bug 25814 if (isset($fieldDef['name'])) { if (stristr($this->getFieldType($fieldDef), 'decimal') && isset($fieldDef['len'])) { $fieldDef['len'] = min($fieldDef['len'], 38); } } $type = $this->getFieldType($fieldDef); if ($this->isTextType($type) && isset($fieldDef['len'])) { unset($fieldDef['len']); } return parent::oneColumnSQLRep($fieldDef, $ignoreRequired, $table, $return_as_array); }