From 5d45636b9e02ade0ca0536045d5bf37682510f45 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Sun, 14 May 2017 14:11:42 +0200 Subject: [PATCH] export: Support dropping non-table objects in SQL export --- src/sqlitedb.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/sqlitedb.cpp b/src/sqlitedb.cpp index e5bae960..478a5c40 100644 --- a/src/sqlitedb.cpp +++ b/src/sqlitedb.cpp @@ -503,7 +503,7 @@ bool DBBrowserDB::dump(const QString& filename, if(exportSchema) { if(!keepOldSchema) - stream << "DROP TABLE IF EXISTS " << sqlb::escapeIdentifier((*it)->name()) << ";\n"; + stream << QString("DROP TABLE IF EXISTS %1;\n").arg(sqlb::escapeIdentifier((*it)->name())); if((*it)->fullyParsed()) stream << (*it)->sql(true) << "\n"; @@ -613,6 +613,11 @@ bool DBBrowserDB::dump(const QString& filename, // Write the SQL string used to create this object to the output file if(!(*it)->originalSql().isEmpty()) { + if(!keepOldSchema) + stream << QString("DROP %1 IF EXISTS %2;\n") + .arg(sqlb::Object::typeToString((*it)->type()).toUpper()) + .arg(sqlb::escapeIdentifier((*it)->name())); + if((*it)->fullyParsed()) stream << (*it)->sql(true) << "\n"; else