-
Notifications
You must be signed in to change notification settings - Fork 8
PR-244: replace any unknown #264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -485,13 +485,13 @@ pub async fn translate_expr( | |
| ts_query.insert_param(&inferred_type, &false, &Some(placeholder.to_string())) | ||
| } | ||
| Expr::JsonAccess { value: _, path: _ } => { | ||
| ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, false, expr_for_logging)?; | ||
| ts_query.insert_param(&TsFieldType::Any, &false, &None) | ||
| ts_query.insert_result(alias, &[TsFieldType::Unknown], is_selection, false, expr_for_logging)?; | ||
| ts_query.insert_param(&TsFieldType::Unknown, &false, &None) | ||
| } | ||
|
Comment on lines
487
to
490
|
||
| Expr::IsNotDistinctFrom(_, placeholder) | Expr::IsDistinctFrom(_, placeholder) => { | ||
| // IsDistinctFrom and IsNotDistinctFrom are the same and can have a placeholder | ||
| ts_query.insert_param(&TsFieldType::String, &false, &Some(placeholder.to_string()))?; | ||
| ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, false, expr_for_logging) | ||
| ts_query.insert_result(alias, &[TsFieldType::Unknown], is_selection, false, expr_for_logging) | ||
| } | ||
| Expr::SimilarTo { | ||
| negated: _, | ||
|
|
@@ -577,10 +577,12 @@ pub async fn translate_expr( | |
| ts_query.insert_result(alias, &[TsFieldType::String], is_selection, false, expr_for_logging) | ||
| } | ||
| Expr::Collate { expr: _, collation: _ } => { | ||
| ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, false, expr_for_logging) | ||
| ts_query.insert_result(alias, &[TsFieldType::Unknown], is_selection, false, expr_for_logging) | ||
| } | ||
| Expr::TypedString(_) => ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, false, expr_for_logging), | ||
| Expr::Map(_) => ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, false, expr_for_logging), | ||
| Expr::TypedString(_) => { | ||
| ts_query.insert_result(alias, &[TsFieldType::Unknown], is_selection, false, expr_for_logging) | ||
| } | ||
| Expr::Map(_) => ts_query.insert_result(alias, &[TsFieldType::Unknown], is_selection, false, expr_for_logging), | ||
| // Note: AggregateExpressionWithFilter was removed in sqlparser 0.59.0 | ||
| // Aggregate functions with filters are now part of the Function variant | ||
| Expr::Case { | ||
|
|
@@ -589,22 +591,22 @@ pub async fn translate_expr( | |
| else_result: _, | ||
| case_token: _, | ||
| end_token: _, | ||
| } => ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, false, expr_for_logging), | ||
| } => ts_query.insert_result(alias, &[TsFieldType::Unknown], is_selection, false, expr_for_logging), | ||
| Expr::Exists { subquery, negated: _ } => { | ||
| ts_query.insert_result(alias, &[TsFieldType::Boolean], is_selection, false, expr_for_logging)?; | ||
| translate_query(ts_query, &None, subquery, db_conn, alias, false).await | ||
| } | ||
| // Note: ListAgg and ArrayAgg were removed in sqlparser 0.59.0 | ||
| // They are now represented as Function variants | ||
| Expr::GroupingSets(_) | Expr::Cube(_) | Expr::Rollup(_) | Expr::Tuple(_) | Expr::Array(_) => { | ||
| ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, false, expr_for_logging) | ||
| ts_query.insert_result(alias, &[TsFieldType::Unknown], is_selection, false, expr_for_logging) | ||
| } | ||
| // Note: ArrayIndex was replaced with CompoundFieldAccess in sqlparser 0.59.0 | ||
| // CompoundFieldAccess handles array indexing, map access, and composite field access | ||
| Expr::CompoundFieldAccess { | ||
| root: _, | ||
| access_chain: _, | ||
| } => ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, false, expr_for_logging), | ||
| } => ts_query.insert_result(alias, &[TsFieldType::Unknown], is_selection, false, expr_for_logging), | ||
| Expr::Interval(_) => ts_query.insert_result(alias, &[TsFieldType::Number], is_selection, false, expr_for_logging), | ||
| Expr::MatchAgainst { | ||
| columns: _, | ||
|
|
@@ -655,7 +657,13 @@ pub async fn translate_expr( | |
| FunctionArguments::List(arg_list) => &arg_list.args, | ||
| _ => { | ||
| // If no arguments or subquery, return Any | ||
| return ts_query.insert_result(Some(alias), &[TsFieldType::Any], is_selection, false, expr_for_logging); | ||
| return ts_query.insert_result( | ||
| Some(alias), | ||
| &[TsFieldType::Unknown], | ||
| is_selection, | ||
|
Comment on lines
658
to
+663
|
||
| false, | ||
| expr_for_logging, | ||
| ); | ||
| } | ||
| }; | ||
|
|
||
|
|
@@ -680,7 +688,13 @@ pub async fn translate_expr( | |
| FunctionArguments::List(arg_list) => &arg_list.args, | ||
| _ => { | ||
| // If no arguments or subquery, return Any | ||
| return ts_query.insert_result(Some(alias), &[TsFieldType::Any], is_selection, false, expr_for_logging); | ||
| return ts_query.insert_result( | ||
| Some(alias), | ||
| &[TsFieldType::Unknown], | ||
| is_selection, | ||
|
Comment on lines
689
to
+694
|
||
| false, | ||
| expr_for_logging, | ||
| ); | ||
| } | ||
| }; | ||
|
|
||
|
|
@@ -723,7 +737,13 @@ pub async fn translate_expr( | |
| expr_for_logging, | ||
| )?; | ||
| } else { | ||
| ts_query.insert_result(Some(alias), &[TsFieldType::Any], is_selection, false, expr_for_logging)?; | ||
| ts_query.insert_result( | ||
| Some(alias), | ||
| &[TsFieldType::Unknown], | ||
| is_selection, | ||
| false, | ||
| expr_for_logging, | ||
| )?; | ||
| } | ||
|
|
||
| Ok(()) | ||
|
|
@@ -756,8 +776,8 @@ pub async fn translate_expr( | |
| expr: _, | ||
| array_expr: _, | ||
| negated: _, | ||
| } => ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, false, expr_for_logging), | ||
| _ => ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, false, expr_for_logging), | ||
| } => ts_query.insert_result(alias, &[TsFieldType::Unknown], is_selection, false, expr_for_logging), | ||
| _ => ts_query.insert_result(alias, &[TsFieldType::Unknown], is_selection, false, expr_for_logging), | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -116,6 +116,7 @@ pub enum TsFieldType { | |||||
| Null, | ||||||
| Enum(Vec<String>), | ||||||
| Any, | ||||||
| Unknown, | ||||||
| #[allow(dead_code)] | ||||||
| Array2D(Array2DContent), | ||||||
| Array(Box<TsFieldType>), | ||||||
|
|
@@ -149,6 +150,7 @@ impl fmt::Display for TsFieldType { | |||||
| TsFieldType::Any => write!(f, "any"), | ||||||
| TsFieldType::Null => write!(f, "null"), | ||||||
| TsFieldType::Never => write!(f, "never"), | ||||||
| TsFieldType::Unknown => write!(f, "unknown"), | ||||||
| TsFieldType::Array(ts_field_type) => { | ||||||
| let ts_field_type = ts_field_type.clone(); | ||||||
| let ts_field_type = *ts_field_type; | ||||||
|
|
@@ -201,17 +203,17 @@ impl TsFieldType { | |||||
| "character" | "character varying" | "bytea" | "uuid" | "text" => Self::String, | ||||||
| "boolean" => Self::Boolean, | ||||||
| "json" | "jsonb" => Self::Object, | ||||||
| "ARRAY" | "array" => Self::Any, | ||||||
| "ARRAY" | "array" => Self::Unknown, | ||||||
|
||||||
| "ARRAY" | "array" => Self::Unknown, | |
| "ARRAY" | "array" => Self::Array(Box::new(Self::Unknown)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment says this fallback "return[s] Any", but the implementation now returns
TsFieldType::Unknown. Please update the comment to avoid misleading readers.