sea-schema
sea-schema copied to clipboard
Determine SQLite type by following affinity rule
I'm currently in the process of migrating a program from sqlite to sea-orm and used sea-orm-codegen to generate the entities from the existing database.
It seems it converted an UNSIGNED SMALLINT NOT NULL
to a Vec<u8>
The database table used to be created like this:
conn.execute(
"CREATE TABLE IF NOT EXISTS users ( userId INTEGER PRIMARY KEY NOT NULL, username TEXT NOT NULL COLLATE NOCASE, hash BLOB NOT NULL, salt BLOB NOT NULL, online_name TEXT NOT NULL, avatar_url TEXT NOT NULL, email TEXT NOT NULL, email_check TEXT NOT NULL, token TEXT NOT NULL, rst_token TEXT, flags UNSIGNED SMALLINT NOT NULL)",
[],
)
.expect("Failed to create users table!");
resulting users.rs:
//! SeaORM Entity. Generated by sea-orm-codegen 0.8.0
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "users")]
pub struct Model {
#[sea_orm(column_name = "userId", primary_key, auto_increment = false)]
pub user_id: i32,
pub username: String,
pub hash: Vec<u8>,
pub salt: Vec<u8>,
pub online_name: String,
pub avatar_url: String,
pub email: String,
pub email_check: String,
pub token: String,
pub rst_token: Option<String>,
pub flags: Vec<u8>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::dates::Entity")]
Dates,
}
impl Related<super::dates::Entity> for Entity {
fn to() -> RelationDef {
Relation::Dates.def()
}
}
impl ActiveModelBehavior for ActiveModel {}
I'd expect pub flags: u16