diff --git a/src/iso19111/factory.cpp b/src/iso19111/factory.cpp index 6baa8daeb1..95c21b788f 100644 --- a/src/iso19111/factory.cpp +++ b/src/iso19111/factory.cpp @@ -1282,18 +1282,15 @@ void DatabaseContext::Private::attachExtraDatabases( sqlite_handle, true, nLayoutVersionMajor, nLayoutVersionMinor); l_handle = sqlite_handle_; - run("ATTACH DATABASE '" + replaceAll(databasePath_, "'", "''") + - "' AS db_0"); + run("ATTACH DATABASE ? AS db_0", {databasePath_}); detach_ = true; int count = 1; for (const auto &otherDbPath : auxiliaryDatabasePaths) { const auto attachedDbName("db_" + toString(static_cast(count))); - std::string sql = "ATTACH DATABASE '"; - sql += replaceAll(otherDbPath, "'", "''"); - sql += "' AS "; + std::string sql = "ATTACH DATABASE ? AS "; sql += attachedDbName; count++; - run(sql); + run(sql, {otherDbPath}); l_handle->checkDatabaseLayout(databasePath_, otherDbPath, attachedDbName + '.');