()
| 1155 | #[test] |
| 1156 | #[cfg(feature = "macros")] |
| 1157 | fn save_as_1() { |
| 1158 | use crate::{ActiveModelTrait, ActiveValue, Update}; |
| 1159 | |
| 1160 | mod hello_expanded { |
| 1161 | use crate as sea_orm; |
| 1162 | use crate::entity::prelude::*; |
| 1163 | use crate::sea_query::{Expr, SimpleExpr}; |
| 1164 | |
| 1165 | #[derive(Copy, Clone, Default, Debug, DeriveEntity)] |
| 1166 | pub struct Entity; |
| 1167 | |
| 1168 | impl EntityName for Entity { |
| 1169 | fn table_name(&self) -> &str { |
| 1170 | "hello" |
| 1171 | } |
| 1172 | } |
| 1173 | |
| 1174 | #[derive(Clone, Debug, PartialEq, Eq, DeriveModel, DeriveActiveModel)] |
| 1175 | pub struct Model { |
| 1176 | pub id: i32, |
| 1177 | #[sea_orm(enum_name = "One1")] |
| 1178 | pub one: i32, |
| 1179 | pub two: i32, |
| 1180 | #[sea_orm(enum_name = "Three3")] |
| 1181 | pub three: i32, |
| 1182 | } |
| 1183 | |
| 1184 | #[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] |
| 1185 | pub enum Column { |
| 1186 | Id, |
| 1187 | One1, |
| 1188 | Two, |
| 1189 | Three3, |
| 1190 | } |
| 1191 | |
| 1192 | impl ColumnTrait for Column { |
| 1193 | type EntityName = Entity; |
| 1194 | |
| 1195 | fn def(&self) -> ColumnDef { |
| 1196 | match self { |
| 1197 | Column::Id => ColumnType::Integer.def(), |
| 1198 | Column::One1 => ColumnType::Integer.def(), |
| 1199 | Column::Two => ColumnType::Integer.def(), |
| 1200 | Column::Three3 => ColumnType::Integer.def(), |
| 1201 | } |
| 1202 | } |
| 1203 | |
| 1204 | fn save_as(&self, val: Expr) -> SimpleExpr { |
| 1205 | match self { |
| 1206 | Self::Two => val.cast_as("text"), |
| 1207 | _ => self.save_enum_as(val), |
| 1208 | } |
| 1209 | } |
| 1210 | } |
| 1211 | |
| 1212 | #[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] |
| 1213 | pub enum PrimaryKey { |
| 1214 | Id, |
nothing calls this directly
no test coverage detected