Open garyrob opened 8 months ago
The missing important bit of information is, what's the Entity being generated like?
I'm having the same issue, here's one of my generated models:
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.14
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "Category")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub key: Option<i32>,
pub name: Option<String>,
pub icon: Option<String>,
#[sea_orm(
column_name = "deleteOK",
column_type = "Binary(BlobSize::Blob(None))",
nullable
)]
pub delete_ok: Option<Vec<u8>>,
#[sea_orm(column_name = "seqNum")]
pub seq_num: Option<i32>,
#[sea_orm(column_name = "deviceIdKey")]
pub device_id_key: Option<i32>,
#[sea_orm(column_name = "deviceKey")]
pub device_key: Option<i32>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}
The key is typed as Option<i32>
and that doesn't compile.
same problem.
Any update on this? Also encountering this issue in my project
Description
If I create an sqlite database with
id INTEGER PRIMARY KEY AUTOINCREMENT
, and then runsea-orm-cli generate entity
, I get aSteps to Reproduce
Initialize a cargo project called test_id. All paths and commands are from the root of that project.
Cargo.toml should contain:
[dependencies] sea-orm = "0.12.10" # Check for the latest version tokio = { version = "1", features = ["full"] }
CREATE TABLE IF NOT EXISTS "tasks" ( id INTEGER PRIMARY KEY AUTOINCREMENT, task_num INTEGER NOT NULL UNIQUE );
mod entities;
[tokio::main]
async fn main() {
Option<i32>: sea_orm::ActiveEnum
is not satisfied --> src/entities/tasks.rs:9:13sea_orm::ActiveEnum
is not implemented forOption<i32>
= help: the following other types implement trait
TryFromU64
: bool i8 i16 i32 i64 u8 u16 u32 and 29 others = note: required forOption<i32>
to implementTryFromU64
note: required by a bound insea_orm::PrimaryKeyTrait::ValueType
--> /Users/garyrob/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sea-orm-0.12.10/src/entity/primary_key.rs:49:11 | 42 | type ValueType: Sized | --------- required by a bound in this associated type ... 49 | + TryFromU64; | ^^^^^^^^^^ required by this bound inPrimaryKeyTrait::ValueType
For more information about this error, try
rustc --explain E0277
. error: could not compiletest_id
(bin "test_id") due to previous error➜ test_id git:(master) ✗ cargo tree | grep sea- ├── sea-orm v0.12.10 │ ├── sea-orm-macros v0.12.10 (proc-macro) │ │ ├── sea-bae v0.2.0 (proc-macro) │ ├── sea-query v0.30.6