Akonadi
querybuilder.cpp
101static void appendJoined(QString *statement, const QStringList &strings, QLatin1StringView glue = QLatin1StringView(", "))
141QueryBuilder::QueryBuilder(DataStore *store, const QSqlQuery &tableQuery, const QString &tableQueryAlias)
236void QueryBuilder::addJoin(JoinType joinType, const QString &table, const Query::Condition &condition)
258void QueryBuilder::addValueCondition(const QString &column, Query::CompareOperator op, const QVariant &value, ConditionType type)
264void QueryBuilder::addValueCondition(const QString &column, Query::CompareOperator op, const QList<qint64> &value, ConditionType type)
270void QueryBuilder::addValueCondition(const QString &column, Query::CompareOperator op, const QSet<qint64> &value, ConditionType type)
276void QueryBuilder::addColumnCondition(const QString &column, Query::CompareOperator op, const QString &column2, ConditionType type)
436 Q_ASSERT_X(mColumnValues.count() >= 1, "QueryBuilder::exec()", "At least one column needs to be changed");
479 Q_ASSERT_X(mType == Select, "QueryBuilder::exec()", "Order statements are only valid for SELECT queries");
535 if (!isBatch && static_cast<QMetaType::Type>(mBindValues[i].typeId()) == qMetaTypeId<QVariantList>()) {
551 StorageDebugger::instance()->queryExecuted(reinterpret_cast<qint64>(mDataStore), mQuery, t.elapsed());
567 qCWarning(AKONADISERVER_LOG) << "QueryBuilder::exec(): database reported transaction deadlock, retrying transaction";
575 qCWarning(AKONADISERVER_LOG) << "QueryBuilder::exec(): database reported transaction deadlock, retrying transaction";
579 qCWarning(AKONADISERVER_LOG) << "QueryBuilder::exec(): database reported transaction timeout, retrying transaction";
581 // Not sure retrying helps, maybe error is good enough.... but doesn't hurt to retry a few times before giving up.
588 qCWarning(AKONADISERVER_LOG) << "QueryBuilder::exec(): database reported transaction deadlock, retrying transaction";
680 if (value.typeId() == qMetaTypeId<QVariantList>() || value.typeId() == qMetaTypeId<QStringList>() || value.typeId() == qMetaTypeId<QByteArrayList>()) {
696 constexpr auto buildWhereInContainerCondition = [](QueryBuilder *self, QString *query, const auto &values) {
729 // FIXME: Ideally we would explicitly convert to QList<T> instead of doing the potentially costly
853 Q_ASSERT_X(query.isValid() && query.isSelect(), "QueryBuilder::getTableQuery", "Table subquery use only for valid SELECT queries");
Helper class to construct arbitrary SQL queries.
Definition querybuilder.h:33
void addValueCondition(const QString &column, Query::CompareOperator op, const QVariant &value, ConditionType type=WhereCondition)
Add a WHERE or HAVING condition which compares a column with a given value.
Definition querybuilder.cpp:258
void setDatabaseType(DbType::Type type)
Sets the database which should execute the query.
Definition querybuilder.cpp:231
void addSortColumn(const QString &column, Query::SortOrder order=Query::Ascending)
Add sort column.
Definition querybuilder.cpp:766
QString getTableWithColumn(const QString &column) const
Returns concatenated table name with column name.
Definition querybuilder.cpp:846
void addJoin(JoinType joinType, const QString &table, const Query::Condition &condition)
Join a table to the query.
Definition querybuilder.cpp:236
void addColumns(const QStringList &cols)
Adds the given columns to a select query.
Definition querybuilder.cpp:619
void addCondition(const Query::Condition &condition, ConditionType type=WhereCondition)
Add a WHERE condition.
Definition querybuilder.cpp:760
void setColumnValue(const QString &column, const QVariant &value)
Sets a column to the given value (only valid for INSERT and UPDATE queries).
Definition querybuilder.cpp:783
void setColumnValues(const QString &column, const QList< T > &values)
Set column to given values (only valid for INSERT query).
Definition querybuilder.h:258
void setDistinct(bool distinct)
Specify whether duplicates should be included in the result.
Definition querybuilder.cpp:797
void addColumnCondition(const QString &column, Query::CompareOperator op, const QString &column2, ConditionType type=WhereCondition)
Add a WHERE or HAVING condition which compares a column with another column.
Definition querybuilder.cpp:276
void addGroupColumns(const QStringList &columns)
Add list of columns to GROUP BY.
Definition querybuilder.cpp:777
void setForUpdate(bool forUpdate=true)
Indicate to the database to acquire an exclusive lock on the rows already during SELECT statement.
Definition querybuilder.cpp:836
ConditionType
Defines the place at which a condition should be evaluated.
Definition querybuilder.h:61
@ HavingCondition
add condition to HAVING part of the query NOTE: only supported for SELECT queries
Definition querybuilder.h:66
void setIdentificationColumn(const QString &column)
Sets the column used for identification in an INSERT statement.
Definition querybuilder.cpp:808
qint64 insertId()
Returns the ID of the newly created record (only valid for INSERT queries)
Definition querybuilder.cpp:813
void setSubQueryMode(Query::LogicOperator op, ConditionType type=WhereCondition)
Define how WHERE or HAVING conditions are combined.
Definition querybuilder.cpp:754
void addAggregation(const QString &col, const QString &aggregate)
Adds an aggregation statement.
Definition querybuilder.cpp:636
void addColumn(const QString &col)
Adds the given column to a select query.
Definition querybuilder.cpp:624
QueryBuilder(const QString &table, QueryType type=Select)
Creates a new query builder.
Definition querybuilder.cpp:111
JoinType
When the same table gets joined as both, Inner- and LeftJoin, it will be merged into a single InnerJo...
Definition querybuilder.h:49
QString getTable() const
Returns the name of the main table or subquery.
Definition querybuilder.cpp:841
void setLimit(int limit, int offset=-1)
Limits the amount of retrieved rows.
Definition querybuilder.cpp:802
void addColumnCondition(const QString &column, CompareOperator op, const QString &column2)
Add a WHERE condition which compares a column with another column.
Definition query.cpp:22
void setSubQueryMode(LogicOperator op)
Set how sub-conditions should be combined, default is And.
Definition query.cpp:49
void addValueCondition(const QString &column, CompareOperator op, const QVariant &value)
Add a WHERE condition which compares a column with a given value.
Definition query.cpp:12
void insert(const QSqlDatabase &db, const QString &queryStatement, QSqlQuery query)
Insert query into the cache for queryStatement.
Definition querycache.cpp:106
std::optional< QSqlQuery > query(const QString &queryStatement)
Return a cached QSqlQuery for given queryStatement.
Definition querycache.cpp:101
QString name(GameStandardAction id)
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
KOSM_EXPORT const char * typeName(Type type)
qint64 elapsed() const const
void start()
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
void clear()
qsizetype count() const const
reference emplace_back(Args &&... args)
bool empty() const const
reference front()
bool isEmpty() const const
void push_back(parameter_type value)
qsizetype size() const const
Type
int id() const const
virtual QString formatValue(const QSqlField &field, bool trimStrings) const const
QString databaseText() const const
QString nativeErrorCode() const const
QString text() const const
void bindValue(const QString &placeholder, const QVariant &val, QSql::ParamType paramType)
QVariantList boundValues() const const
const QSqlDriver * driver() const const
bool exec()
bool execBatch(BatchExecutionMode mode)
QString executedQuery() const const
void finish()
bool first()
bool isActive() const const
bool isSelect() const const
bool isValid() const const
QSqlError lastError() const const
QVariant lastInsertId() const const
QString lastQuery() const const
bool next()
bool prepare(const QString &query)
QSqlRecord record() const const
void setForwardOnly(bool forward)
QVariant value(const QString &name) const const
QString & append(QChar ch)
const QChar at(qsizetype position) const const
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
qsizetype indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
QString left(qsizetype n) const const
QString number(double n, char format, int precision)
QString & prepend(QChar ch)
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
void reserve(qsizetype size)
void resize(qsizetype newSize, QChar fillChar)
int toInt(bool *ok, int base) const const
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
bool isNull() const const
bool isValid() const const
QMetaType metaType() const const
QDateTime toDateTime() const const
QList< QVariant > toList() const const
qlonglong toLongLong(bool *ok) const const
int typeId() const const
const char * typeName() const const
T value() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:31:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:31:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.