Skip to content

Commit

Permalink
export: Support dropping non-table objects in SQL export
Browse files Browse the repository at this point in the history
  • Loading branch information
MKleusberg committed May 14, 2017
1 parent a370957 commit 5d45636
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/sqlitedb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5d45636

Please sign in to comment.