1 #ifndef SQLITEINSERT_H 2 #define SQLITEINSERT_H 3 4 #include "sqlitequery.h" 5 #include "sqliteconflictalgo.h" 6 #include <QString> 7 #include <QList> 8 9 class SqliteSelect; 10 class SqliteExpr; 11 class SqliteWith; 12 class SqliteUpsert; 13 14 class API_EXPORT SqliteInsert : public SqliteQuery 15 { 16 public: 17 SqliteInsert(); 18 SqliteInsert(const SqliteInsert& other); 19 SqliteInsert(bool replace, SqliteConflictAlgo onConflict, const QString& name1, 20 const QString& name2, const QList<QString>& columns, 21 const QList<SqliteExpr*>& row, SqliteWith* with); 22 SqliteInsert(bool replace, SqliteConflictAlgo onConflict, const QString& name1, 23 const QString& name2, const QList<QString>& columns, SqliteSelect* select, SqliteWith* with, SqliteUpsert* upsert = nullptr); 24 SqliteInsert(bool replace, SqliteConflictAlgo onConflict, const QString& name1, 25 const QString& name2, const QList<QString>& columns, SqliteWith* with); 26 ~SqliteInsert(); 27 28 SqliteStatement* clone(); 29 30 protected: 31 QStringList getColumnsInStatement(); 32 QStringList getTablesInStatement(); 33 QStringList getDatabasesInStatement(); 34 TokenList getColumnTokensInStatement(); 35 TokenList getTableTokensInStatement(); 36 TokenList getDatabaseTokensInStatement(); 37 QList<FullObject> getFullObjectsInStatement(); 38 TokenList rebuildTokensFromContents(); 39 40 private: 41 void initName(const QString& name1, const QString& name2); 42 void initMode(bool replace, SqliteConflictAlgo onConflict); 43 44 public: 45 bool replaceKw = false; 46 bool defaultValuesKw = false; 47 SqliteConflictAlgo onConflict = SqliteConflictAlgo::null; 48 QString database = QString(); 49 QString table = QString(); 50 QStringList columnNames; 51 QList<SqliteExpr*> values; 52 SqliteSelect* select = nullptr; 53 SqliteWith* with = nullptr; 54 SqliteUpsert* upsert = nullptr; 55 }; 56 57 typedef QSharedPointer<SqliteInsert> SqliteInsertPtr; 58 59 #endif // SQLITEINSERT_H 60