Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src-tauri/src/drivers/mysql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,8 @@ pub async fn create_view(
let text = resolve_text_proto(&pool, params).await?;
let escaped_name = escape_identifier(view_name);
let query = format!("CREATE VIEW `{}` AS {}", escaped_name, definition);
exec_stmt(&pool, text, &query)
sqlx::raw_sql(&query)
.execute(&pool)
.await
.map_err(|e| format!("Failed to create view: {}", e))?;
Ok(())
Expand All @@ -950,7 +951,11 @@ pub async fn alter_view(
let text = resolve_text_proto(&pool, params).await?;
let escaped_name = escape_identifier(view_name);
let query = format!("ALTER VIEW `{}` AS {}", escaped_name, definition);
exec_stmt(&pool, text, &query)
// `ALTER VIEW` is not supported by MySQL's prepared-statement protocol
// (server error 1295), so it must go through `raw_sql()` (text protocol)
// rather than `sqlx::query()`. See `is_text_protocol_stmt` for context.
sqlx::raw_sql(&query)
.execute(&pool)
.await
.map_err(|e| format!("Failed to alter view: {}", e))?;
Ok(())
Expand All @@ -961,7 +966,11 @@ pub async fn drop_view(params: &ConnectionParams, view_name: &str) -> Result<(),
let text = resolve_text_proto(&pool, params).await?;
let escaped_name = escape_identifier(view_name);
let query = format!("DROP VIEW IF EXISTS `{}`", escaped_name);
exec_stmt(&pool, text, &query)
// Routed through `raw_sql()` (text protocol) for consistency with
// create/alter view, which the prepared-statement protocol rejects
// with server error 1295.
sqlx::raw_sql(&query)
.execute(&pool)
.await
.map_err(|e| format!("Failed to drop view: {}", e))?;
Ok(())
Expand Down
Loading