Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1624 committed Oct 27, 2021
1 parent a1f57ec commit e04495b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
4 changes: 1 addition & 3 deletions src/query/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ where
for (idx, col) in <A::Entity as EntityTrait>::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 {
Expand All @@ -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(),
};
Expand Down
3 changes: 1 addition & 2 deletions src/query/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
Expand Down
3 changes: 1 addition & 2 deletions src/query/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,10 @@ where
if <A::Entity as EntityTrait>::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(),
};
Expand Down

0 comments on commit e04495b

Please sign in to comment.