diff options
author | Marco Bubke <[email protected]> | 2021-06-10 15:48:22 +0200 |
---|---|---|
committer | Marco Bubke <[email protected]> | 2021-06-14 12:08:31 +0000 |
commit | b32f607bc7e6ee1dba3372b3f63afa769f279bb0 (patch) | |
tree | fd871d6200a8d70713f85cd56247e6c2245051b5 /src/libs/sqlite/sqliteindex.h | |
parent | 66ba9c4843bdf11b6e5cd50b5f83b256b2df250c (diff) |
Sqlite: Add condition to index
Change-Id: I83851b2f9cd516f21bc7e8987c1b60efaa019bb1
Reviewed-by: Thomas Hartmann <[email protected]>
Reviewed-by: Qt CI Bot <[email protected]>
Diffstat (limited to 'src/libs/sqlite/sqliteindex.h')
-rw-r--r-- | src/libs/sqlite/sqliteindex.h | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/libs/sqlite/sqliteindex.h b/src/libs/sqlite/sqliteindex.h index 11d83541af1..d8f4d7c61da 100644 --- a/src/libs/sqlite/sqliteindex.h +++ b/src/libs/sqlite/sqliteindex.h @@ -43,14 +43,16 @@ enum class IndexType class Index { public: - Index(Utils::SmallString &&tableName, + Index(Utils::SmallStringView tableName, Utils::SmallStringVector &&columnNames, - IndexType indexType=IndexType::Normal) - : m_tableName(std::move(tableName)), - m_columnNames(std::move(columnNames)), - m_indexType(indexType) - { - } + IndexType indexType = IndexType::Normal, + Utils::SmallStringView condition = {}) + : m_tableName(std::move(tableName)) + , m_columnNames(std::move(columnNames)) + , m_indexType(indexType) + , m_condition{condition} + + {} Utils::SmallString sqlStatement() const { @@ -67,7 +69,9 @@ public: m_tableName, "(", m_columnNames.join(", "), - ")"}); + ")", + m_condition.hasContent() ? " WHERE " : "", + m_condition}); } void checkTableName() const @@ -86,6 +90,7 @@ private: Utils::SmallString m_tableName; Utils::SmallStringVector m_columnNames; IndexType m_indexType; + Utils::SmallString m_condition; }; using SqliteIndices = std::vector<Index>; |