mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
Pretty-print CREATE statements in SQL export
When exporting a database to an SQL file, output the CREATE statements in a standardised format, including line breaks, indentation and proper quoting. This requires our grammar parser to fully understand the schema of a database object in order to make sure no information is lost during the export. Because of this we fall back to the old way of doing this for all database objects that couldn't be fully parsed. See issue #629.
This commit is contained in:
@@ -496,7 +496,12 @@ bool DBBrowserDB::dump(const QString& filename,
|
||||
|
||||
// Write the SQL string used to create this table to the output file
|
||||
if(exportSchema)
|
||||
stream << (*it)->originalSql() << ";\n";
|
||||
{
|
||||
if((*it)->fullyParsed())
|
||||
stream << (*it)->sql() << "\n";
|
||||
else
|
||||
stream << (*it)->originalSql() << ";\n";
|
||||
}
|
||||
|
||||
// If the user doesn't want the data to be exported skip the rest of the loop block here
|
||||
if(!exportData)
|
||||
@@ -599,7 +604,12 @@ bool DBBrowserDB::dump(const QString& filename,
|
||||
|
||||
// Write the SQL string used to create this object to the output file
|
||||
if(!(*it)->originalSql().isEmpty())
|
||||
stream << (*it)->originalSql() << ";\n";
|
||||
{
|
||||
if((*it)->fullyParsed())
|
||||
stream << (*it)->sql() << "\n";
|
||||
else
|
||||
stream << (*it)->originalSql() << ";\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user