Revision 506067a2
Von Christian Ehringfeld vor mehr als 10 Jahren hinzugefügt
| src/queryinterpreter.cpp | ||
|---|---|---|
|
*/
|
||
|
|
||
|
#include "queryinterpreter.h"
|
||
|
#include "condition.h"
|
||
|
#include "join.h"
|
||
|
#include "query.h"
|
||
|
#include "querybuilder.h"
|
||
| ... | ... | |
|
re.optimize();
|
||
|
QRegularExpressionMatchIterator iterator = re.globalMatch(nExp, 0,
|
||
|
QRegularExpression::PartialPreferFirstMatch);
|
||
|
|
||
|
if (iterator.hasNext()) {
|
||
|
for (int var = 0; var < 2; ++var) {
|
||
|
QRegularExpressionMatch match = iterator.next();
|
||
| ... | ... | |
|
QString::number(i));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
} else {
|
||
|
nExp = this->builder->getSchema()->quoteColumnName(nExp);
|
||
|
}
|
||
| ... | ... | |
|
Join j = joins.at(i);
|
||
|
sqlJoin += j.getType() + this->builder->getSeparator() +
|
||
|
this->builder->getSchema()->quoteTableName(j.getForeignTable());
|
||
|
if (!j.getCondition().getConditions().isEmpty()) {
|
||
|
QString condition = this->buildCondition(j.getCondition());
|
||
|
if (!condition.isEmpty()) {
|
||
|
sqlJoin += " ON " + condition;
|
||
|
}
|
||
|
if (!j.getExpression().getExpression().isEmpty()) {
|
||
|
sqlJoin += " ON " + j.getExpression().getExpression();
|
||
|
}
|
||
|
}
|
||
|
return sqlJoin;
|
||
|
}
|
||
|
|
||
|
QString QueryInterpreter::buildWhere(const QList<Condition> &conditions)
|
||
|
QString QueryInterpreter::buildWhere(const QList<Expression> &conditions)
|
||
|
const {
|
||
|
QString where = this->buildCondition(conditions);
|
||
|
return where.isEmpty() ? "" : ("WHERE " + where);
|
||
| ... | ... | |
|
groupBy);
|
||
|
}
|
||
|
|
||
|
QString QueryInterpreter::buildHaving(const QList<Condition> &conditions)
|
||
|
QString QueryInterpreter::buildHaving(const QList<Expression> &conditions)
|
||
|
const {
|
||
|
QString having = this->buildCondition(conditions);
|
||
|
return having.isEmpty() ? "" : ("HAVING " + having);
|
||
| ... | ... | |
|
return sqlOrder;
|
||
|
}
|
||
|
|
||
|
QString QueryInterpreter::buildCondition(const QList<Condition> &conditions)
|
||
|
QString QueryInterpreter::buildCondition(const QList<Expression> &conditions)
|
||
|
const {
|
||
|
if (conditions.isEmpty()) {
|
||
|
return "";
|
||
|
}
|
||
|
return "";
|
||
|
}
|
||
|
|
||
|
QString QueryInterpreter::buildCondition(const Condition &conditions) const {
|
||
|
return "";
|
||
|
QString sqlCondition = "";
|
||
|
bool first = true;
|
||
|
for (int i = 0; i < conditions.size(); ++i) {
|
||
|
Expression exp = conditions.at(i);
|
||
|
QString expression = exp.getExpression();
|
||
|
if (!expression.isEmpty()) {
|
||
|
if (first) {
|
||
|
first = false;
|
||
|
} else if (expression.at(0) != ' ') {
|
||
|
sqlCondition += this->builder->getSeparator();
|
||
|
}
|
||
|
}
|
||
|
sqlCondition += expression;
|
||
|
}
|
||
|
return sqlCondition;
|
||
|
}
|
||
|
|
||
Auch abrufbar als: Unified diff
some improvements