diff --git a/src/query/insert.rs b/src/query/insert.rs index f8b151d7b..f7f77d7d0 100644 --- a/src/query/insert.rs +++ b/src/query/insert.rs @@ -124,8 +124,6 @@ where for (idx, col) in ::Column::iter().enumerate() { let av = am.take(col); let av_has_val = av.is_set() || av.is_unchanged(); - let col_def = col.def(); - if columns_empty { self.columns.push(av_has_val); } else if self.columns[idx] != av_has_val { @@ -134,7 +132,7 @@ where if av_has_val { columns.push(col); let val = Expr::val(av.into_value().unwrap()); - let expr = match col_def.get_column_type().get_enum_name() { + let expr = match col.def().get_column_type().get_enum_name() { Some(enum_name) => val.as_enum(Alias::new(enum_name)), None => val.into(), }; diff --git a/src/query/select.rs b/src/query/select.rs index 037527c76..5e433e8a4 100644 --- a/src/query/select.rs +++ b/src/query/select.rs @@ -118,9 +118,8 @@ where let text_type = SeaRc::new(Alias::new("text")) as DynIden; E::Column::iter() .map(|col| { - let col_def = col.def(); let expr = Expr::tbl(table.clone(), col); - match col_def.get_column_type().get_enum_name() { + match col.def().get_column_type().get_enum_name() { Some(_) => expr.as_enum(text_type.clone()), None => expr.into(), } diff --git a/src/query/update.rs b/src/query/update.rs index 7c2e9c2e6..89348229a 100644 --- a/src/query/update.rs +++ b/src/query/update.rs @@ -104,11 +104,10 @@ where if ::PrimaryKey::from_column(col).is_some() { continue; } - let col_def = col.def(); let av = self.model.get(col); if av.is_set() { let val = Expr::val(av.into_value().unwrap()); - let expr = match col_def.get_column_type().get_enum_name() { + let expr = match col.def().get_column_type().get_enum_name() { Some(enum_name) => val.as_enum(Alias::new(enum_name)), None => val.into(), };