sequelize-auto icon indicating copy to clipboard operation
sequelize-auto copied to clipboard

bug: enum name image will generate BLOB

Open bobby169 opened this issue 1 year ago • 0 comments

CREATE TABLE `asset_list` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `type` enum('video','audio','image') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'video',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

static initModel(sequelize: Sequelize.Sequelize): typeof asset_list { return sequelize.define( 'asset_list', { id: { autoIncrement: true, type: DataTypes.INTEGER.UNSIGNED, allowNull: false, primaryKey: true, }, type: { type: DataTypes.BLOB, // this is error allowNull: false, defaultValue: 'video', },

When I change sql to the following:

CREATE TABLE `asset_list` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `type` enum('video','audio','img') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'video',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

Rename the image to img, and the data generated is correct.

static initModel(sequelize: Sequelize.Sequelize): typeof asset_list { return sequelize.define( 'asset_list', { id: { autoIncrement: true, type: DataTypes.INTEGER.UNSIGNED, allowNull: false, primaryKey: true, }, type: { type: DataTypes.ENUM('video', 'audio', 'img'), allowNull: false, defaultValue: 'video', },

bobby169 avatar Dec 23 '24 15:12 bobby169