aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecreateindex.h
blob: b8876a2077a2912ff18dbb03a64eb8fe078699d5 (plain) (blame)
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
48
49
50
51
52
53
54
55
56
57
58
#ifndef SQLITECREATEINDEX_H
#define SQLITECREATEINDEX_H

#include "sqlitequery.h"
#include "sqlitetablerelatedddl.h"
#include "sqliteconflictalgo.h"
#include "sqliteexpr.h"
#include "sqliteddlwithdbcontext.h"
#include "sqliteorderby.h"
#include <QString>
#include <QList>

class SqliteIndexedColumn;

class API_EXPORT SqliteCreateIndex : public SqliteQuery, public SqliteTableRelatedDdl, public SqliteDdlWithDbContext
{
    public:
        SqliteCreateIndex();
        SqliteCreateIndex(const SqliteCreateIndex& other);
        SqliteCreateIndex(bool unique, bool ifNotExists, const QString& name1, const QString& name2,
                          const QString& name3, const QList<SqliteIndexedColumn*>& columns,
                          SqliteConflictAlgo onConflict = SqliteConflictAlgo::null);
        SqliteCreateIndex(bool unique, bool ifNotExists, const QString& name1, const QString& name2,
                          const QString& name3, const QList<SqliteOrderBy*>& columns,
                          SqliteExpr* where);
        ~SqliteCreateIndex();
        SqliteStatement* clone();

        QString getTargetTable() const;
        QString getTargetDatabase() const;
        void setTargetDatabase(const QString& database);
        QString getObjectName() const;
        void setObjectName(const QString& name);

        bool uniqueKw = false;
        bool ifNotExistsKw = false;
        QList<SqliteOrderBy*> indexedColumns;
        QString database = QString();
        QString index = QString();
        QString table = QString();
        SqliteConflictAlgo onConflict = SqliteConflictAlgo::null;
        SqliteExpr* where = nullptr;

    protected:
        QStringList getTablesInStatement();
        QStringList getDatabasesInStatement();
        TokenList getTableTokensInStatement();
        TokenList getDatabaseTokensInStatement();
        QList<FullObject> getFullObjectsInStatement();
        TokenList rebuildTokensFromContents();

    private:
        QList<SqliteOrderBy*> toOrderColumns(const QList<SqliteIndexedColumn*>& columns);
};

typedef QSharedPointer<SqliteCreateIndex> SqliteCreateIndexPtr;

#endif // SQLITECREATEINDEX_H