Skip to content

Commit

Permalink
Add error test
Browse files Browse the repository at this point in the history
  • Loading branch information
MRGRAVITY817 committed Feb 5, 2022
1 parent 4a261c8 commit 3056085
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/src/translate/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub enum TranslateError {
JoinOnUpdateNotSupported,

#[error("unimplemented - compound identifier on update not supported: {0}")]
CompoundIndentOnUpdateNotSupported(String),
CompoundIdentOnUpdateNotSupported(String),

#[error("too many params in drop index")]
TooManyParamsInDropIndex,
Expand Down
2 changes: 1 addition & 1 deletion core/src/translate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ fn translate_assignment(sql_assignment: &SqlAssignment) -> Result<Assignment> {

if id.len() > 1 {
return Err(
TranslateError::CompoundIndentOnUpdateNotSupported(sql_assignment.to_string()).into(),
TranslateError::CompoundIdentOnUpdateNotSupported(sql_assignment.to_string()).into(),
);
}

Expand Down
12 changes: 12 additions & 0 deletions test-suite/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ test_case!(error, async move {
TranslateError::UnsupportedJoinOperator("CrossJoin".to_owned()).into(),
"SELECT * FROM TableA CROSS JOIN TableA as A;",
),
(
TranslateError::JoinOnUpdateNotSupported.into(),
"UPDATE TableA INNER JOIN TableA ON 1 = 1 SET 1 = 1",
),
(
TranslateError::UnsupportedTableFactor("(SELECT * FROM TableA)".to_owned()).into(),
"UPDATE (SELECT * FROM TableA) SET 1 = 1",
),
(
TranslateError::CompoundIdentOnUpdateNotSupported("TableA.id = 1".to_owned()).into(),
"UPDATE TableA SET TableA.id = 1 WHERE id = 1",
),
(
EvaluateError::NestedSelectRowNotFound.into(),
"SELECT * FROM TableA WHERE id = (SELECT id FROM TableA WHERE id = 2);",
Expand Down

0 comments on commit 3056085

Please sign in to comment.