sea-orm-cli 1.0 generate entity from mysql generates String for MediumBlob fields
Open
Nobody has claimed this yet.
Area:schema
- Dominant language
- Rust
- Stars
- 9.9k
- Forks
- 734
- Avg merge
- 6h 36m
- Merged PRs (30d)
- 8
Description
I defined a mediumblob field using this code:
ColumnDef::new(MyTable::SharingPhoto).custom(MySqlType::MediumBlob)
When I generate an entity file using the command
sea-orm-cli generate entity --with-serde=both -l -o ./entity/src/
the type of the field in the generated entity file becomes a String type:
pub struct Model {
#[sea_orm(column_type = "custom(\"mediumblob\")")]
pub sharing_photo: Option<String>,
}
Under such circumstances, if I query data from the database, this error occurs:
error=Query Error: error occurred while decoding column "sharing_photo": mismatched types; Rust type `core::option::Option<alloc::string::String>` (as SQL type `VARCHAR`) is not compatible with SQL type `BLOB`
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 by reproducing the issue with the shown sea-orm-cli generate entity command and inspect the generated entity file for the MediumBlob column. Trace the generator's MySQL type mapping, then verify the generated field uses a blob-compatible Rust type and that querying the column no longer produces the reported decoding mismatch.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, rust
- Domain
- cli, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100