fix(mysql): treat desc as result-set query

This commit is contained in:
t8y2 committed 2026-05-28 18:36:13 +08:00
1 parent a036ea1e8d
commit 832d8276a0
3 files changed
+24 -9

No files matched your search

+12 -1
View File
@@ -701,7 +701,12 @@ pub fn starts_with_executable_sql_keyword_with_options(
let Some(token) = first_executable_sql_token_with_options(sql, options) else {
return false;
};
keywords.iter().any(|keyword| token.eq_ignore_ascii_case(keyword))
keywords.iter().any(|keyword| executable_sql_keyword_matches(token, keyword))
}
fn executable_sql_keyword_matches(token: &str, keyword: &str) -> bool {
token.eq_ignore_ascii_case(keyword)
|| (keyword.eq_ignore_ascii_case("DESCRIBE") && token.eq_ignore_ascii_case("DESC"))
}
fn is_mysql_compatible_import_target(db_type: &DatabaseType, driver_profile: Option<&str>) -> bool {
@@ -1170,6 +1175,12 @@ mod tests {
assert!(starts_with_executable_sql_keyword("/*M! SELECT 1 */", &["SELECT"]));
}
#[test]
fn describe_keyword_detection_accepts_desc_shorthand() {
assert!(starts_with_executable_sql_keyword("DESC users", &["DESCRIBE"]));
assert!(starts_with_executable_sql_keyword("-- comment\nDESC users", &["DESCRIBE"]));
}
#[test]
fn mysql_hash_comments_are_ignored_for_keyword_detection() {
assert!(starts_with_executable_sql_keyword_for_database(