Skip to content

Commit

Permalink
Fix SQL import of files with BOM
Browse files Browse the repository at this point in the history
This fixes the import of SQL files with a leading BOM.

See issue #2323.
  • Loading branch information
MKleusberg committed Jul 8, 2020
1 parent d089a60 commit 7c3cce5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "FindReplaceDialog.h"
#include "RunSql.h"
#include "ExtendedTableWidget.h"
#include "Data.h"

#include <chrono>
#include <QFile>
Expand Down Expand Up @@ -1407,7 +1408,9 @@ void MainWindow::importDatabaseFromSQL()
QApplication::setOverrideCursor(Qt::WaitCursor);
QFile f(fileName);
f.open(QIODevice::ReadOnly);
bool ok = db.executeMultiSQL(f.readAll(), newDbFile.size() == 0);
QByteArray data = f.readAll();
removeBom(data);
bool ok = db.executeMultiSQL(data, newDbFile.size() == 0);
// Restore cursor before asking the user to accept the message
QApplication::restoreOverrideCursor();
if(!ok)
Expand Down

0 comments on commit 7c3cce5

Please sign in to comment.