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 authored and mgrojo committed Aug 22, 2020
1 parent 13686c8 commit 0f54d04
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 @@ -1418,7 +1419,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 0f54d04

Please sign in to comment.