sea-orm-cli generate entity got wrong mediumblob type
Open
Nobody has claimed this yet.
Area:code-gen
- Dominant language
- Rust
- Stars
- 9.9k
- Forks
- 734
- Avg merge
- 6h 36m
- Merged PRs (30d)
- 8
Description
Description
mysql 8.4.2 table:
CREATE TABLE `public_kv_tab`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'primary id',
`kv_key` varchar(255) NOT NULL COMMENT 'key',
`kv_key_type` tinyint unsigned NOT NULL COMMENT 'kv_key_type',
`kv_value` mediumblob NOT NULL COMMENT 'value',
`kv_value2` BLOB NOT NULL COMMENT 'value',
`create_time` bigint NOT NULL COMMENT 'create time, timestamp',
`update_time` bigint NOT NULL COMMENT 'update time, timestamp',
PRIMARY KEY (`id`),
UNIQUE KEY `idx_kv_key_kv_key_type` (`kv_key`, `kv_key_type`) COMMENT 'idx_kv_key_kv_key_type'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
sea-orm-cli-1.1.7 generate entity
sea-orm-cli generate entity -u mysql://test:123456@127.0.0.1/test -o src/entity
got entity
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.7
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "public_kv_tab")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i64,
pub kv_key: String,
pub kv_key_type: u8,
#[sea_orm(column_type = "custom(\"mediumblob\")")]
pub kv_value: String,
#[sea_orm(column_type = "Binary(255)")]
pub kv_value2: Vec<u8>,
pub create_time: i64,
pub update_time: i64,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}
Actual Behavior
#[sea_orm(column_type = "custom(\"mediumblob\")")]
pub kv_value: String,
#[sea_orm(column_type = "Binary(255)")]
pub kv_value2: Vec<u8>,
Hi, BLOB type could be 65535 size, is this Binary(255) correct? And mediumblob should be Vec instead of String.
And how could I fix these when using sea-orm-cli?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the sea-orm-cli generate entity entry point and inspect how MySQL BLOB types are mapped in the generated entity. Reproduce the schema from the issue, then verify that mediumblob and BLOB generate byte-vector fields with appropriate column types rather than String or Binary(255).
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, rust
- Domain
- cli, database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100