()
| 1286 | #[test] |
| 1287 | #[cfg(feature = "macros")] |
| 1288 | fn select_as_and_value_1() { |
| 1289 | use crate::{ActiveModelTrait, ActiveValue, Update}; |
| 1290 | |
| 1291 | mod hello_expanded { |
| 1292 | use crate as sea_orm; |
| 1293 | use crate::entity::prelude::*; |
| 1294 | use crate::sea_query::{Expr, SimpleExpr}; |
| 1295 | |
| 1296 | #[derive(Copy, Clone, Default, Debug, DeriveEntity)] |
| 1297 | pub struct Entity; |
| 1298 | |
| 1299 | impl EntityName for Entity { |
| 1300 | fn table_name(&self) -> &str { |
| 1301 | "hello" |
| 1302 | } |
| 1303 | } |
| 1304 | |
| 1305 | #[derive(Clone, Debug, PartialEq, Eq, DeriveModel, DeriveActiveModel)] |
| 1306 | pub struct Model { |
| 1307 | pub id: i32, |
| 1308 | #[sea_orm(enum_name = "One1")] |
| 1309 | pub one: i32, |
| 1310 | pub two: i32, |
| 1311 | #[sea_orm(enum_name = "Three3")] |
| 1312 | pub three: i32, |
| 1313 | } |
| 1314 | |
| 1315 | #[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] |
| 1316 | pub enum Column { |
| 1317 | Id, |
| 1318 | One1, |
| 1319 | Two, |
| 1320 | Three3, |
| 1321 | } |
| 1322 | |
| 1323 | impl ColumnTrait for Column { |
| 1324 | type EntityName = Entity; |
| 1325 | |
| 1326 | fn def(&self) -> ColumnDef { |
| 1327 | match self { |
| 1328 | Column::Id => ColumnType::Integer.def(), |
| 1329 | Column::One1 => ColumnType::Integer.def(), |
| 1330 | Column::Two => ColumnType::Integer.def(), |
| 1331 | Column::Three3 => ColumnType::Integer.def(), |
| 1332 | } |
| 1333 | } |
| 1334 | |
| 1335 | fn select_as(&self, expr: Expr) -> SimpleExpr { |
| 1336 | match self { |
| 1337 | Self::Two => expr.cast_as("integer"), |
| 1338 | _ => self.select_enum_as(expr), |
| 1339 | } |
| 1340 | } |
| 1341 | |
| 1342 | fn save_as(&self, val: Expr) -> SimpleExpr { |
| 1343 | match self { |
| 1344 | Self::Two => val.cast_as("text"), |
| 1345 | _ => self.save_enum_as(val), |
nothing calls this directly
no test coverage detected