Fix attaching an unencrypted database to an encrypted database

When opening a plain database and trying to attach an unencrypted
database we need to explicitly specify that there is no key for the
attached database. Otherwise SQLCipher is going to use the same key as
for the main database which results in an error.

See issue #1814.
This commit is contained in:
Martin Kleusberg
2019-03-25 18:02:44 +01:00
parent 217563fd47
commit 05cb45d1f7
+2
View File
@@ -249,6 +249,8 @@ bool DBBrowserDB::attach(const QString& filePath, QString attach_as)
QString key;
if(cipherSettings && is_encrypted)
key = "KEY " + cipherSettings->getPassword();
else
key = "KEY ''";
if(!executeSQL(QString("ATTACH '%1' AS %2 %3").arg(filePath).arg(sqlb::escapeIdentifier(attach_as)).arg(key), false))
{