Updates
This commit is contained in:
@@ -10,11 +10,18 @@ const data_type_parser_1 = __importDefault(require("../../utils/db/schema/data-t
|
||||
* # Generate Table Column Description
|
||||
*/
|
||||
function generateColumnDescription({ columnData, primaryKeySet, }) {
|
||||
const { fieldName, dataType, nullValue, primaryKey, autoIncrement, defaultValue, defaultValueLiteral, onUpdateLiteral, notNullValue, unique, } = columnData;
|
||||
const { fieldName, dataType, nullValue, primaryKey, autoIncrement, defaultValue, defaultValueLiteral, onUpdateLiteral, notNullValue, unique, options, } = columnData;
|
||||
let fieldEntryText = "";
|
||||
const finalDataTypeObject = (0, data_type_parser_1.default)(dataType);
|
||||
const finalDataType = (0, data_type_constructor_1.default)(finalDataTypeObject.type, finalDataTypeObject.limit, finalDataTypeObject.decimal);
|
||||
fieldEntryText += `\`${fieldName}\` ${finalDataType}`;
|
||||
if (finalDataType.match(/enum/i) && (options === null || options === void 0 ? void 0 : options[0])) {
|
||||
fieldEntryText += `\`${fieldName}\` ${finalDataType}(${options
|
||||
.map((opt) => `'${opt}'`)
|
||||
.join(",")})`;
|
||||
}
|
||||
else {
|
||||
fieldEntryText += `\`${fieldName}\` ${finalDataType}`;
|
||||
}
|
||||
if (nullValue) {
|
||||
fieldEntryText += " DEFAULT NULL";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user