Revision 2316d17f
Von Christian Ehringfeld vor fast 10 Jahren hinzugefügt
| src/queryinterpreter.cpp | ||
|---|---|---|
|
return sqlSelect + "*";
|
||
|
}
|
||
|
bool first = true;
|
||
|
int paramCount = 0;
|
||
|
for (int i = 0; i < columns.size(); ++i) {
|
||
|
if (first) {
|
||
|
first = false;
|
||
| ... | ... | |
|
sqlSelect += ", ";
|
||
|
}
|
||
|
Expression e = columns.at(i);
|
||
|
q.appendParams(e.getParams());
|
||
|
QString nExp = e.getExpression();
|
||
|
auto params = e.getParams();
|
||
|
this->convertParams("s", params, nExp, paramCount);
|
||
|
q.appendParams(params);
|
||
|
if (e.getOnlyColumn()) {
|
||
|
sqlSelect += this->ar->getQb()->getSchema()->quoteColumnName(e.getExpression());
|
||
|
} else if (!nExp.contains("(")) {
|
||
| ... | ... | |
|
return sqlOrder;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
QString QueryInterpreter::buildCondition(Query &q,
|
||
|
const QList<Expression> &conditions) const {
|
||
|
if (conditions.isEmpty()) {
|
||
| ... | ... | |
|
}
|
||
|
QString sqlCondition = "";
|
||
|
bool first = true;
|
||
|
int paramCount = 0;
|
||
|
for (int i = 0; i < conditions.size(); ++i) {
|
||
|
Expression exp = conditions.at(i);
|
||
|
QString expression = exp.getExpression();
|
||
| ... | ... | |
|
sqlCondition += this->ar->getQb()->getSeparator();
|
||
|
}
|
||
|
}
|
||
|
auto params = exp.getParams();
|
||
|
this->convertParams("p", params, expression, paramCount);
|
||
|
sqlCondition += expression;
|
||
|
q.appendParams(exp.getParams());
|
||
|
q.appendParams(params);
|
||
|
}
|
||
|
return sqlCondition;
|
||
|
}
|
||
|
|
||
|
void QueryInterpreter::convertParams(const QString &prefix,
|
||
|
QHash<QString, QVariant> ¶ms, QString &condition, int &start) const {
|
||
|
auto keys = params.keys();
|
||
|
for (int i = 0; i < keys.size(); ++i) {
|
||
|
QString val = prefix + QString::number(start);
|
||
|
condition.replace(this->ar->getQb()->placeHolder(keys.at(i)),
|
||
|
this->ar->getQb()->placeHolder(val));
|
||
|
params.insert(val, params.value(keys.at(i)));
|
||
|
params.remove(keys.at(i));
|
||
|
++start;
|
||
|
}
|
||
|
}
|
||
Auch abrufbar als: Unified diff
querybuilder params get own notations