Skip to content

Commit

Permalink
Manually implement TryFromU64 due to sea-orm issues #1364
Browse files Browse the repository at this point in the history
[sea-orm #1364](SeaQL/sea-orm#1364)
  • Loading branch information
Pure-Peace committed Jan 5, 2023
1 parent 61d2a2a commit 7191450
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion frame/dal/src/db/peace/entity/sea_orm_active_enums.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.5
use sea_orm::entity::prelude::*;
use sea_orm::{entity::prelude::*, TryFromU64};

#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "game_mode")]
Expand Down Expand Up @@ -96,3 +96,27 @@ pub enum ScoreVersion {
#[sea_orm(string_value = "v2")]
V2,
}

/// Manually implement [`TryFromU64`] due to [sea-orm #3513](https://github.com/SeaQL/sea-orm/issues/1364)
impl TryFromU64 for PerformanceVersion {
fn try_from_u64(n: u64) -> Result<Self, sea_orm::DbErr> {
match n {
0 => Ok(Self::V1),
1 => Ok(Self::V2),
_ => Err(sea_orm::DbErr::Type(format!("Invalid value {}", n))),
}
}
}

/// Manually implement [`TryFromU64`] due to [sea-orm #3513](https://github.com/SeaQL/sea-orm/issues/1364)
impl TryFromU64 for RankingType {
fn try_from_u64(n: u64) -> Result<Self, sea_orm::DbErr> {
match n {
0 => Ok(Self::PerformanceV1),
1 => Ok(Self::PerformanceV2),
2 => Ok(Self::ScoreV1),
3 => Ok(Self::ScoreV2),
_ => Err(sea_orm::DbErr::Type(format!("Invalid value {}", n))),
}
}
}

0 comments on commit 7191450

Please sign in to comment.