* sqlite: deps * sqlite: update data type mappings * sqlite: decimal test cases * sqlite: try negative numbers * fixup * fixup * fmt * clippy * fixup * fixup * fixup * refactor * fix * Drop the use of `rust_decimal_macros` (#2078) * sqlite: decimal -> real * revert * Bump dependencies * Fixup * Fixup * Fixup * Fixup * Refactor * Refactor * Refactor
57 lines
1.1 KiB
Rust
57 lines
1.1 KiB
Rust
use arraystring::{typenum::U32, ArrayString};
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
pub type TableName = ArrayString<U32>;
|
|
|
|
#[derive(Copy, Clone, Default, Debug, DeriveEntity)]
|
|
pub struct Entity {
|
|
pub table_name: TableName,
|
|
}
|
|
|
|
impl EntityName for Entity {
|
|
fn table_name(&self) -> &str {
|
|
self.table_name.as_str()
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveModel, DeriveActiveModel)]
|
|
pub struct Model {
|
|
pub id: i32,
|
|
pub name: String,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
|
|
pub enum Column {
|
|
Id,
|
|
Name,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)]
|
|
pub enum PrimaryKey {
|
|
Id,
|
|
}
|
|
|
|
impl PrimaryKeyTrait for PrimaryKey {
|
|
type ValueType = i32;
|
|
|
|
fn auto_increment() -> bool {
|
|
true
|
|
}
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {}
|
|
|
|
impl ColumnTrait for Column {
|
|
type EntityName = Entity;
|
|
|
|
fn def(&self) -> ColumnDef {
|
|
match self {
|
|
Self::Id => ColumnType::Integer.def(),
|
|
Self::Name => ColumnType::string(None).def(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|