File: sqlitedropindex.cpp

package info (click to toggle)
sqlitestudio 3.4.21%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 54,880 kB
  • sloc: ansic: 406,208; cpp: 123,872; yacc: 2,692; tcl: 497; sh: 462; xml: 426; makefile: 19
file content (78 lines) | stat: -rw-r--r-- 1,813 bytes parent folder | download
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "sqlitedropindex.h"
#include "sqlitequerytype.h"

#include <parser/statementtokenbuilder.h>

SqliteDropIndex::SqliteDropIndex()
{
    queryType = SqliteQueryType::DropIndex;
}

SqliteDropIndex::SqliteDropIndex(const SqliteDropIndex& other) :
    SqliteQuery(other), ifExistsKw(other.ifExistsKw), database(other.database), index(other.index)
{
}

SqliteDropIndex::SqliteDropIndex(bool ifExists, const QString &name1, const QString &name2)
    : SqliteDropIndex()
{
    this->ifExistsKw = ifExists;
    if (!name2.isNull())
    {
        database = name1;
        index = name2;
    }
    else
        index = name1;
}

SqliteStatement*SqliteDropIndex::clone()
{
    return new SqliteDropIndex(*this);
}

QStringList SqliteDropIndex::getDatabasesInStatement()
{
    return getStrListFromValue(database);
}

TokenList SqliteDropIndex::getDatabaseTokensInStatement()
{
    return getDbTokenListFromFullname();
}

QList<SqliteStatement::FullObject> SqliteDropIndex::getFullObjectsInStatement()
{
    QList<FullObject> result;

    // Index object
    FullObject fullObj = getFullObjectFromFullname(FullObject::INDEX);

    if (fullObj.isValid())
        result << fullObj;

    // Db object
    fullObj = getFirstDbFullObject();
    if (fullObj.isValid())
        result << fullObj;

    return result;
}


TokenList SqliteDropIndex::rebuildTokensFromContents()
{
    StatementTokenBuilder builder;
    builder.withTokens(SqliteQuery::rebuildTokensFromContents());
    builder.withKeyword("DROP").withSpace().withKeyword("INDEX").withSpace();

    if (ifExistsKw)
        builder.withKeyword("IF").withSpace().withKeyword("EXISTS").withSpace();

    if (!database.isNull())
        builder.withOther(database).withOperator(".");

    builder.withOther(index).withOperator(";");

    return builder.build();
}