From 8b38916fba843a7b84f2c0f3d77baa93dc64a6f1 Mon Sep 17 00:00:00 2001 From: Egor Vorontsov Date: Sat, 7 Jun 2025 00:17:51 +0300 Subject: [PATCH 1/3] Fixed incorrect expected/inferred order in `UnexpectedType` error for SQL `UPDATE`. --- crates/expr/src/statement.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/expr/src/statement.rs b/crates/expr/src/statement.rs index 39abf447118..2974b3a2b5b 100644 --- a/crates/expr/src/statement.rs +++ b/crates/expr/src/statement.rs @@ -132,10 +132,10 @@ pub fn type_insert(insert: SqlInsert, tx: &impl SchemaView) -> TypingResult { - return Err(UnexpectedType::new(&AlgebraicType::Bool, ty).into()); + return Err(UnexpectedType::new(ty, &AlgebraicType::Bool).into()); } (SqlLiteral::Str(_), _) => { - return Err(UnexpectedType::new(&AlgebraicType::String, ty).into()); + return Err(UnexpectedType::new(ty, &AlgebraicType::String).into()); } (SqlLiteral::Hex(v), ty) | (SqlLiteral::Num(v), ty) => { values.push(parse(&v, ty).map_err(|_| InvalidLiteral::new(v.into_string(), ty))?); @@ -199,10 +199,10 @@ pub fn type_update(update: SqlUpdate, tx: &impl SchemaView) -> TypingResult { - return Err(UnexpectedType::new(&AlgebraicType::Bool, ty).into()); + return Err(UnexpectedType::new(ty, &AlgebraicType::Bool).into()); } (SqlLiteral::Str(_), _) => { - return Err(UnexpectedType::new(&AlgebraicType::String, ty).into()); + return Err(UnexpectedType::new(ty, &AlgebraicType::String).into()); } (SqlLiteral::Hex(v), ty) | (SqlLiteral::Num(v), ty) => { values.push(( From da5c7ea0efed48554a4a53b53669632c1152a574 Mon Sep 17 00:00:00 2001 From: Egor Vorontsov Date: Fri, 6 Jun 2025 23:55:28 +0300 Subject: [PATCH 2/3] Allowed specifying timestamp literals in SQL. --- crates/expr/src/statement.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/crates/expr/src/statement.rs b/crates/expr/src/statement.rs index 2974b3a2b5b..81be358bc1c 100644 --- a/crates/expr/src/statement.rs +++ b/crates/expr/src/statement.rs @@ -128,16 +128,10 @@ pub fn type_insert(insert: SqlInsert, tx: &impl SchemaView) -> TypingResult { values.push(AlgebraicValue::Bool(v)); } - (SqlLiteral::Str(v), AlgebraicType::String) => { - values.push(AlgebraicValue::String(v)); - } (SqlLiteral::Bool(_), _) => { return Err(UnexpectedType::new(ty, &AlgebraicType::Bool).into()); } - (SqlLiteral::Str(_), _) => { - return Err(UnexpectedType::new(ty, &AlgebraicType::String).into()); - } - (SqlLiteral::Hex(v), ty) | (SqlLiteral::Num(v), ty) => { + (SqlLiteral::Num(v), ty) | (SqlLiteral::Hex(v), ty) | (SqlLiteral::Str(v), ty) => { values.push(parse(&v, ty).map_err(|_| InvalidLiteral::new(v.into_string(), ty))?); } } From 5b93aa3db042046b8d7bc5bed493fd5ab5d62102 Mon Sep 17 00:00:00 2001 From: Egor Vorontsov Date: Mon, 9 Jun 2025 02:46:05 +0300 Subject: [PATCH 3/3] Expanded timestamp literal support to `UPDATE`. --- crates/expr/src/statement.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/crates/expr/src/statement.rs b/crates/expr/src/statement.rs index 81be358bc1c..f2dabe2e13c 100644 --- a/crates/expr/src/statement.rs +++ b/crates/expr/src/statement.rs @@ -189,16 +189,10 @@ pub fn type_update(update: SqlUpdate, tx: &impl SchemaView) -> TypingResult { values.push((*col_id, AlgebraicValue::Bool(v))); } - (SqlLiteral::Str(v), AlgebraicType::String) => { - values.push((*col_id, AlgebraicValue::String(v))); - } (SqlLiteral::Bool(_), _) => { return Err(UnexpectedType::new(ty, &AlgebraicType::Bool).into()); } - (SqlLiteral::Str(_), _) => { - return Err(UnexpectedType::new(ty, &AlgebraicType::String).into()); - } - (SqlLiteral::Hex(v), ty) | (SqlLiteral::Num(v), ty) => { + (SqlLiteral::Num(v), ty) | (SqlLiteral::Hex(v), ty) | (SqlLiteral::Str(v), ty) => { values.push(( *col_id, parse(&v, ty).map_err(|_| InvalidLiteral::new(v.into_string(), ty))?,