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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
#ifndef SQLITECREATETRIGGER_H
#define SQLITECREATETRIGGER_H
#include "sqliteddlwithdbcontext.h"
#include "sqlitequery.h"
#include "sqlitetablerelatedddl.h"
#include <QString>
#include <QList>
class SqliteExpr;
class API_EXPORT SqliteCreateTrigger : public SqliteQuery, public SqliteTableRelatedDdl, public SqliteDdlWithDbContext
{
Q_OBJECT
public:
enum class Time
{
BEFORE,
AFTER,
INSTEAD_OF,
null
};
class API_EXPORT Event : public SqliteStatement
{
public:
enum Type
{
INSERT,
UPDATE,
DELETE,
UPDATE_OF,
null
};
Event();
explicit Event(Type type);
Event(const Event& other);
explicit Event(const QList<QString>& columns);
SqliteStatement* clone();
TokenList rebuildTokensFromContents();
static QString typeToString(Type type);
static Type stringToType(const QString& type);
Type type;
QStringList columnNames;
};
enum class Scope
{
FOR_EACH_ROW,
FOR_EACH_STATEMENT, // Sqlite2 only
null
};
SqliteCreateTrigger();
SqliteCreateTrigger(const SqliteCreateTrigger& other);
SqliteCreateTrigger(int temp, bool ifNotExists, const QString& name1, const QString& name2,
const QString& name3, Time time, Event* event, Scope scope,
SqliteExpr* precondition, const QList<SqliteQuery*>& queries, int sqliteVersion);
~SqliteCreateTrigger();
SqliteStatement* clone();
QString getTargetTable() const;
QString getTargetDatabase() const;
void setTargetDatabase(const QString& database);
QString getObjectName() const;
void setObjectName(const QString& name);
bool tempKw = false;
bool temporaryKw = false;
bool ifNotExistsKw = false;
QString database = QString();
QString trigger = QString();
QString table = QString(); // can also be a view name
Event* event = nullptr;
Time eventTime = Time::null;
Scope scope = Scope::null;
SqliteExpr* precondition = nullptr;
QList<SqliteQuery*> queries;
static QString time(Time eventTime);
static Time time(const QString& eventTime);
static QString scopeToString(Scope scope);
static Scope stringToScope(const QString& scope);
protected:
QStringList getTablesInStatement();
QStringList getDatabasesInStatement();
TokenList getTableTokensInStatement();
TokenList getDatabaseTokensInStatement();
QList<FullObject> getFullObjectsInStatement();
TokenList rebuildTokensFromContents();
};
typedef QSharedPointer<SqliteCreateTrigger> SqliteCreateTriggerPtr;
#endif // SQLITECREATETRIGGER_H
|