This commit is contained in:
Benjamin Toby
2025-07-28 07:23:45 +01:00
parent a429436939
commit 8ac8b8eb51
49 changed files with 475 additions and 177 deletions
@@ -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";
}