-
-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8aadc9b
commit df79cbf
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
//! SeaORM Entity. Generated by sea-orm-codegen 0.1.0 | ||
//! | ||
//! This file tests that the JsonBinary column type is annotated correctly is | ||
//! expanded entity form. More information can be found in this issue: | ||
//! | ||
//! https://github.com/SeaQL/sea-orm/issues/1344 | ||
use sea_orm::entity::prelude::*; | ||
|
||
#[derive(Copy, Clone, Default, Debug, DeriveEntity)] | ||
pub struct Entity; | ||
impl EntityName for Entity { | ||
fn schema_name(&self) -> Option< &str > { | ||
Some("schema_name") | ||
} | ||
fn table_name(&self) -> &str { | ||
"task" | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq)] | ||
pub struct Model { | ||
pub id: i32, | ||
pub payload: Json, | ||
pub payload_binary: Json, | ||
} | ||
|
||
#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] | ||
pub enum Column { | ||
Id, | ||
Payload, | ||
PayloadBinary, | ||
} | ||
|
||
#[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)] | ||
pub enum Relation {} | ||
impl ColumnTrait for Column { | ||
type EntityName = Entity; | ||
fn def(&self) -> ColumnDef { | ||
match self { | ||
Self::Id => ColumnType::Integer.def(), | ||
// This is the part that is being tested. | ||
Self::Payload => ColumnType::Json.def(), | ||
Self::PayloadBinary => ColumnType::JsonBinary.def(), | ||
} | ||
} | ||
} | ||
impl RelationTrait for Relation { | ||
fn def(&self) -> RelationDef { | ||
panic!("No RelationDef") | ||
} | ||
} | ||
impl ActiveModelBehavior for ActiveModel {} |