Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: enum name image will generate BLOB #674

Open
bobby169 opened this issue Dec 23, 2024 · 0 comments
Open

bug: enum name image will generate BLOB #674

bobby169 opened this issue Dec 23, 2024 · 0 comments

Comments

@bobby169
Copy link

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',
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant