mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-02-09 21:28:30 -06:00
When modifying a view use DROP VIEW IF EXISTS instead of just DROP VIEW
Clicking on Edit View in the database structure tab opens a new SQL tab with a DROP VIEW statement to delete the existing view and a copy of the CREATE VIEW statement used for the current view. When the user modifies the CREATE VIEW statement introduces an error in it, and then executes the statements, the view is deleted and an error reported. Fixing that error and re-running the script then fails at the DROP VIEW statement. This means it makes more sense to make it a DROP VIEW IF EXISTS statement. See issue #2661.
This commit is contained in:
@@ -992,7 +992,7 @@ void MainWindow::editObject()
|
||||
refreshTableBrowsers();
|
||||
} else if(type == "view") {
|
||||
sqlb::TablePtr view = db.getTableByName(obj);
|
||||
runSqlNewTab(QString("DROP VIEW %1;\n%2").arg(QString::fromStdString(obj.toString()), QString::fromStdString(view->sql())),
|
||||
runSqlNewTab(QString("DROP VIEW IF EXISTS %1;\n%2").arg(QString::fromStdString(obj.toString()), QString::fromStdString(view->sql())),
|
||||
tr("Edit View %1").arg(QString::fromStdString(obj.toDisplayString())),
|
||||
"https://www.sqlite.org/lang_createview.html",
|
||||
/* autoRun */ false);
|
||||
|
||||
Reference in New Issue
Block a user