()
| 1024 | #[test] |
| 1025 | #[cfg(feature = "macros")] |
| 1026 | fn select_as_1() { |
| 1027 | use crate::{ActiveModelTrait, ActiveValue, Update}; |
| 1028 | |
| 1029 | mod hello_expanded { |
| 1030 | use crate as sea_orm; |
| 1031 | use crate::entity::prelude::*; |
| 1032 | use crate::sea_query::{Expr, SimpleExpr}; |
| 1033 | |
| 1034 | #[derive(Copy, Clone, Default, Debug, DeriveEntity)] |
| 1035 | pub struct Entity; |
| 1036 | |
| 1037 | impl EntityName for Entity { |
| 1038 | fn table_name(&self) -> &str { |
| 1039 | "hello" |
| 1040 | } |
| 1041 | } |
| 1042 | |
| 1043 | #[derive(Clone, Debug, PartialEq, Eq, DeriveModel, DeriveActiveModel)] |
| 1044 | pub struct Model { |
| 1045 | pub id: i32, |
| 1046 | #[sea_orm(enum_name = "One1")] |
| 1047 | pub one: i32, |
| 1048 | pub two: i32, |
| 1049 | #[sea_orm(enum_name = "Three3")] |
| 1050 | pub three: i32, |
| 1051 | } |
| 1052 | |
| 1053 | #[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] |
| 1054 | pub enum Column { |
| 1055 | Id, |
| 1056 | One1, |
| 1057 | Two, |
| 1058 | Three3, |
| 1059 | } |
| 1060 | |
| 1061 | impl ColumnTrait for Column { |
| 1062 | type EntityName = Entity; |
| 1063 | |
| 1064 | fn def(&self) -> ColumnDef { |
| 1065 | match self { |
| 1066 | Column::Id => ColumnType::Integer.def(), |
| 1067 | Column::One1 => ColumnType::Integer.def(), |
| 1068 | Column::Two => ColumnType::Integer.def(), |
| 1069 | Column::Three3 => ColumnType::Integer.def(), |
| 1070 | } |
| 1071 | } |
| 1072 | |
| 1073 | fn select_as(&self, expr: Expr) -> SimpleExpr { |
| 1074 | match self { |
| 1075 | Self::Two => expr.cast_as("integer"), |
| 1076 | _ => self.select_enum_as(expr), |
| 1077 | } |
| 1078 | } |
| 1079 | } |
| 1080 | |
| 1081 | #[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] |
| 1082 | pub enum PrimaryKey { |
| 1083 | Id, |
nothing calls this directly
no test coverage detected