diff --git a/README.md b/README.md index fc2947bf..fd171985 100755 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ test command ```sql create table t1 (a int, b int); -insert into t1 (a, b) values (1, 1), (5, 3), (5, 2); +insert into t1 (a, b) values (1, 1), (5, 3), (6, 2); update t1 set a = 0 where b > 1; diff --git a/src/binder/insert.rs b/src/binder/insert.rs index cdf3ee14..85164f36 100644 --- a/src/binder/insert.rs +++ b/src/binder/insert.rs @@ -59,7 +59,9 @@ impl Binder { } ScalarExpression::Unary { expr, op, .. } => { if let ScalarExpression::Constant(value) = expr.as_ref() { - row.push(Arc::new(unary_op(value, op)?)) + row.push(Arc::new( + unary_op(value, op)?.cast(columns[i].datatype())?, + )) } else { unreachable!() } diff --git a/src/execution/executor/dml/insert.rs b/src/execution/executor/dml/insert.rs index c7ec4f9a..42993ff9 100644 --- a/src/execution/executor/dml/insert.rs +++ b/src/execution/executor/dml/insert.rs @@ -63,10 +63,9 @@ impl Insert { let mut tuple_map = HashMap::new(); for (i, value) in values.into_iter().enumerate() { let col = &columns[i]; - let cast_val = DataValue::clone(&value).cast(&col.datatype())?; if let Some(col_id) = col.id { - tuple_map.insert(col_id, Arc::new(cast_val)); + tuple_map.insert(col_id, value); } } let primary_col_id = primary_key_index.get_or_insert_with(|| {