aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/guiSQLiteStudio/dbobjectdialogs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/dbobjectdialogs.cpp')
-rw-r--r--SQLiteStudio3/guiSQLiteStudio/dbobjectdialogs.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/SQLiteStudio3/guiSQLiteStudio/dbobjectdialogs.cpp b/SQLiteStudio3/guiSQLiteStudio/dbobjectdialogs.cpp
index 05b614b..42f2841 100644
--- a/SQLiteStudio3/guiSQLiteStudio/dbobjectdialogs.cpp
+++ b/SQLiteStudio3/guiSQLiteStudio/dbobjectdialogs.cpp
@@ -4,6 +4,7 @@
#include "dialogs/triggerdialog.h"
#include "common/utils_sql.h"
#include "dbtree/dbtree.h"
+#include "schemaresolver.h"
#include "services/notifymanager.h"
#include "mdiarea.h"
#include "mdiwindow.h"
@@ -121,27 +122,31 @@ ViewWindow* DbObjectDialogs::editView(const QString& database, const QString& vi
return win;
}
-void DbObjectDialogs::editObject(const QString& name)
+void DbObjectDialogs::editObject(Type type, const QString& name)
{
- editObject("main", name);
+ editObject(type, "main", name);
}
-void DbObjectDialogs::editObject(const QString& database, const QString& name)
+void DbObjectDialogs::editObject(Type type, const QString& database, const QString& name)
{
- Type type = getObjectType(database, name);
+ SchemaResolver schemaResolver(db);
+ QString normalizedName = schemaResolver.normalizeCaseObjectName(database, name);
+ if (type == Type::UNKNOWN)
+ type = getObjectType(database, normalizedName);
+
switch (type)
{
case Type::TABLE:
- editTable(database, name);
+ editTable(database, normalizedName);
break;
case Type::INDEX:
- editIndex(name);
+ editIndex(normalizedName);
break;
case Type::TRIGGER:
- editTrigger(name);
+ editTrigger(normalizedName);
break;
case Type::VIEW:
- editView(database, name);
+ editView(database, normalizedName);
break;
default:
{
@@ -151,19 +156,20 @@ void DbObjectDialogs::editObject(const QString& database, const QString& name)
}
}
-bool DbObjectDialogs::dropObject(const QString& name)
+bool DbObjectDialogs::dropObject(Type type, const QString& name)
{
- return dropObject("main", name);
+ return dropObject(type, "main", name);
}
-bool DbObjectDialogs::dropObject(const QString& database, const QString& name)
+bool DbObjectDialogs::dropObject(Type type, const QString& database, const QString& name)
{
- static const QString dropSql2 = "DROP %1 %2;";
static const QString dropSql3 = "DROP %1 %2.%3;";
QString dbName = wrapObjIfNeeded(database);
- Type type = getObjectType(database, name);
+ if (type == Type::UNKNOWN)
+ type = getObjectType(database, name);
+
QString title;
QString message;
QString typeForSql;
@@ -210,7 +216,7 @@ bool DbObjectDialogs::dropObject(const QString& database, const QString& name)
results = db->exec(finalSql);
if (results->isError())
{
- notifyError(tr("Error while dropping %1: %2").arg(name).arg(results->getErrorText()));
+ notifyError(tr("Error while dropping %1: %2").arg(name, results->getErrorText()));
qCritical() << "Error while dropping object " << database << "." << name << ":" << results->getErrorText();
return false;
}
@@ -366,7 +372,7 @@ void DbObjectDialogs::setNoConfirmation(bool value)
TableWindow* DbObjectDialogs::editTable(const QString& database, const QString& table)
{
TableWindow* win = nullptr;
- for (MdiWindow* mdiWin : mdiArea->getWindows())
+ for (MdiWindow*& mdiWin : mdiArea->getWindows())
{
win = dynamic_cast<TableWindow*>(mdiWin->getMdiChild());
if (!win)