QueryBuilder now uses a StringBuilder internally.

This commit is contained in:
Relintai 2024-04-27 18:54:12 +02:00
parent eebeadbe47
commit 04ef468ffa
3 changed files with 29 additions and 7 deletions

View File

@ -38,7 +38,8 @@ String QueryBuilder::get_result() {
return query_result;
}
void QueryBuilder::set_result(const String &val) {
query_result = val;
query_result.clear();
query_result.append(val);
}
QueryBuilder *QueryBuilder::select() {
@ -235,7 +236,12 @@ QueryBuilder *QueryBuilder::order_by(const String &col) {
QueryBuilder *QueryBuilder::corder_by() {
ERR_FAIL_COND_V(query_result.length() <= 2, this);
query_result[query_result.length() - 2] = ' ';
String qr = query_result.as_string();
qr[qr.length() - 2] = ' ';
query_result.clear();
query_result.append(qr);
return this;
}
@ -307,7 +313,7 @@ QueryBuilder *QueryBuilder::end_command() {
}
QueryBuilder *QueryBuilder::reset() {
query_result = "";
query_result.clear();
return this;
}

View File

@ -33,6 +33,7 @@
/*************************************************************************/
#include "core/string/ustring.h"
#include "core/string/string_builder.h"
#include "core/object/reference.h"
@ -245,7 +246,7 @@ protected:
Ref<QueryBuilder> _reset_bind();
String query_result;
StringBuilder query_result;
};
#endif

View File

@ -24,7 +24,12 @@ QueryBuilder *SQLite3QueryBuilder::del() {
QueryBuilder *SQLite3QueryBuilder::cvalues() {
ERR_FAIL_COND_V(query_result.length() <= 2, this);
query_result[query_result.length() - 2] = ' ';
String qr = query_result.as_string();
qr[qr.length() - 2] = ' ';
query_result.clear();
query_result.append(qr);
query_result += ") ";
return this;
@ -32,7 +37,12 @@ QueryBuilder *SQLite3QueryBuilder::cvalues() {
QueryBuilder *SQLite3QueryBuilder::next_value() {
ERR_FAIL_COND_V(query_result.length() <= 2, this);
query_result[query_result.length() - 2] = ' ';
String qr = query_result.as_string();
qr[qr.length() - 2] = ' ';
query_result.clear();
query_result.append(qr);
query_result += "), (";
return this;
@ -215,7 +225,12 @@ QueryBuilder *SQLite3QueryBuilder::sets() {
QueryBuilder *SQLite3QueryBuilder::cset() {
ERR_FAIL_COND_V(query_result.length() <= 2, this);
query_result[query_result.length() - 2] = ' ';
String qr = query_result.as_string();
qr[qr.length() - 2] = ' ';
query_result.clear();
query_result.append(qr);
return this;
}