MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / save_enum_as

Method save_enum_as

src/entity/column.rs:304–314  ·  view source on GitHub ↗

Cast value of an enum column as enum type; do nothing if `self` is not an enum. Will also transform `Array(Vec )` into `Json(Vec )` if the column type is `Json`.

(&self, val: Expr)

Source from the content-addressed store, hash-verified

302 /// Cast value of an enum column as enum type; do nothing if `self` is not an enum.
303 /// Will also transform `Array(Vec<Json>)` into `Json(Vec<Json>)` if the column type is `Json`.
304 fn save_enum_as(&self, val: Expr) -> SimpleExpr {
305 cast_enum_as(val, self, |col, enum_name, col_type| {
306 let type_name = match col_type {
307 ColumnType::Array(_) => {
308 Alias::new(format!("{}[]", enum_name.to_string())).into_iden()
309 }
310 _ => enum_name,
311 };
312 col.as_enum(type_name)
313 })
314 }
315}
316
317/// SeaORM's utility methods that act on [ColumnType]

Callers 2

save_asMethod · 0.80
save_asMethod · 0.80

Implementers 15

filling.rssrc/tests_cfg/filling.rs
lunch_set_expanded.rssrc/tests_cfg/lunch_set_expanded.rs
cake_filling.rssrc/tests_cfg/cake_filling.rs
cake_filling_price.rssrc/tests_cfg/cake_filling_price.rs
indexes.rssrc/tests_cfg/indexes.rs
cake_expanded.rssrc/tests_cfg/cake_expanded.rs
column_name_2src/entity/column.rs
enum_name_2src/entity/column.rs
column_name_enum_name_2src/entity/column.rs
select_as_1src/entity/column.rs
save_as_1src/entity/column.rs
select_as_and_value_1src/entity/column.rs

Calls 3

cast_enum_asFunction · 0.85
as_enumMethod · 0.80
newFunction · 0.50

Tested by

no test coverage detected