-
Notifications
You must be signed in to change notification settings - Fork 1
/
firebirdsqlquery.cpp
47 lines (35 loc) · 1.19 KB
/
firebirdsqlquery.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "firebirdsqlquery.h"
using namespace SqlUtil4;
FirebirdSqlQuery::FirebirdSqlQuery() : SqlQuery() {
}
QString FirebirdSqlQuery::toString() {
QString query;
if(!selectFields.isEmpty()) {
if(limitResults > 0) {
query += QStringLiteral("SELECT FIRST %1 %2 FROM %3").arg(QString::number(limitResults), selectFields, fromTable);
} else {
query += QStringLiteral("SELECT %1 FROM %2").arg(selectFields, fromTable);
}
} else if(!deleteFromTable.isEmpty()) {
query += QStringLiteral("DELETE FROM %1").arg(deleteFromTable);
}
for(int i = 0; i < joinTables.size(); i++) {
query += joinTables.at(i);
}
if(!conditions.empty()) {
query += QStringLiteral(" WHERE ");
for(const QString & cond : conditions) {
query += cond;
}
}
if(!orderByExpression.isEmpty()) {
query += QStringLiteral(" ORDER BY %1").arg(orderByExpression);
}
if(group.size() > 0) {
query += QStringLiteral(" GROUP BY %1").arg(group.at(0));
for(int i = 1; i < group.size(); i++) {
query += QStringLiteral(", %1").arg(group.at(i));
}
}
return query;
}