SeaORM issue with UUID stored as binary(16) in MySQL #2129
-
I'm using SeaORM in my Rust project and I've encountered an issue when trying to use a UUID as a primary key. MySQL database stores the UUID as binary(16), but it seems like SeaORM is having trouble handling this. Here's the relevant part of my model: #[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "users")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: Uuid,
// other fields...
} And here's how I'm creating a new user: pub async fn create_user(
db: &DbConn,
// other fields...
) -> Result<Model, DbErr> {
let user_id = Uuid::new_v4();
let user = ActiveModel {
id: Set(user_id.to_owned()),
// other fields...
};
// rest of the code...
user.insert(db).await?
} When I try to create a new user, I get the following error: "Error creating user: UnpackInsertId". I believe this error is related to the UUID primary key. Any help would be greatly appreciated |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Checkout the https://github.com/SeaQL/sea-orm/blob/master/tests/uuid_tests.rs |
Beta Was this translation helpful? Give feedback.
Checkout the https://github.com/SeaQL/sea-orm/blob/master/tests/uuid_tests.rs