From db534a3da6c1ae32e6f544b94c5422e94e3f569f Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 27 Dec 2022 18:20:01 +0100 Subject: [PATCH] Use String.empty() instead of comparing a string to "", in the QueryBuilder. --- modules/database/query_builder.cpp | 6 +++--- modules/database_sqlite/sqlite3_query_builder.cpp | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/database/query_builder.cpp b/modules/database/query_builder.cpp index 3b326efa3..ae364fe05 100644 --- a/modules/database/query_builder.cpp +++ b/modules/database/query_builder.cpp @@ -191,7 +191,7 @@ QueryBuilder *QueryBuilder::order_by_desc(const String &col) { return this; } QueryBuilder *QueryBuilder::order_by(const String &col) { - if (col == "") { + if (col.empty()) { query_result += "ORDER BY "; } else { query_result += "ORDER BY " + col + ", "; @@ -213,7 +213,7 @@ QueryBuilder *QueryBuilder::order_by_add_col(const String &col) { return this; } QueryBuilder *QueryBuilder::asc(const String &col) { - if (col == "") { + if (col.empty()) { query_result += "ASC, "; } else { query_result += col + " ASC, "; @@ -222,7 +222,7 @@ QueryBuilder *QueryBuilder::asc(const String &col) { return this; } QueryBuilder *QueryBuilder::desc(const String &col) { - if (col == "") { + if (col.empty()) { query_result += "DESC, "; } else { query_result += col + " DESC, "; diff --git a/modules/database_sqlite/sqlite3_query_builder.cpp b/modules/database_sqlite/sqlite3_query_builder.cpp index a2f5a9f56..0eed0155e 100644 --- a/modules/database_sqlite/sqlite3_query_builder.cpp +++ b/modules/database_sqlite/sqlite3_query_builder.cpp @@ -94,7 +94,7 @@ QueryBuilder *SQLite3QueryBuilder::ndel(const String ¶ms) { QueryBuilder *SQLite3QueryBuilder::nwhere(const String ¶ms) { query_result += "WHERE "; - if (params != "") { + if (!params.empty()) { query_result += params; query_result += " "; } @@ -105,7 +105,7 @@ QueryBuilder *SQLite3QueryBuilder::nwhere(const String ¶ms) { QueryBuilder *SQLite3QueryBuilder::nfrom(const String ¶ms) { query_result += "FROM "; - if (params != "") { + if (!params.empty()) { query_result += params; query_result += " "; } @@ -116,12 +116,12 @@ QueryBuilder *SQLite3QueryBuilder::nfrom(const String ¶ms) { QueryBuilder *SQLite3QueryBuilder::insert(const String &table_name, const String &columns) { query_result += "INSERT INTO "; - if (table_name != "") { + if (!table_name.empty()) { query_result += table_name; query_result += " "; } - if (columns != "") { + if (!columns.empty()) { query_result += "("; query_result += columns; query_result += ") "; @@ -132,7 +132,7 @@ QueryBuilder *SQLite3QueryBuilder::insert(const String &table_name, const String QueryBuilder *SQLite3QueryBuilder::nvalues(const String ¶ms_str) { query_result += "VALUES("; - if (params_str != "") { + if (!params_str.empty()) { query_result += params_str; query_result += ") "; }