From ef7492adfbb107cf9ff4f84b9c48f7fef48ab461 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Fri, 16 Nov 2018 11:05:13 +0100 Subject: [PATCH] Better identifier quoting This commit fixes the SQL export which did not quote the field names in the INSERT statements. This also simplifies the code for escaping SQL identifiers. --- src/sqlitedb.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/sqlitedb.cpp b/src/sqlitedb.cpp index 1587def8..c7c347ad 100644 --- a/src/sqlitedb.cpp +++ b/src/sqlitedb.cpp @@ -734,7 +734,7 @@ bool DBBrowserDB::dump(const QString& filePath, { stream << "INSERT INTO " << sqlb::escapeIdentifier(it->name()); if (insertColNames) - stream << " (" << cols.join(",") << ")"; + stream << " (" << sqlb::escapeIdentifier(cols).join(",") << ")"; stream << " VALUES ("; } else @@ -1139,9 +1139,7 @@ QString DBBrowserDB::emptyInsertStmt(const QString& schemaName, const sqlb::Tabl stmt.append(" DEFAULT VALUES;"); } else { stmt.append("("); - for(const QString& f : fields) - stmt.append(sqlb::escapeIdentifier(f) + ","); - stmt.chop(1); + stmt.append(sqlb::escapeIdentifier(fields).join(",")); stmt.append(") VALUES ("); stmt.append(vals.join(",")); stmt.append(");");