2020-12-01 23:37:10 +01:00
|
|
|
#ifndef TABLE_BUILDER_H
|
|
|
|
#define TABLE_BUILDER_H
|
|
|
|
|
2021-11-01 17:49:10 +01:00
|
|
|
#include "core/string.h"
|
2020-12-01 23:37:10 +01:00
|
|
|
|
2021-08-22 20:41:59 +02:00
|
|
|
#include "core/reference.h"
|
|
|
|
|
2021-08-19 23:55:16 +02:00
|
|
|
class QueryResult;
|
|
|
|
|
2021-08-22 20:41:59 +02:00
|
|
|
class TableBuilder : public Reference {
|
2020-12-01 23:37:10 +01:00
|
|
|
public:
|
2021-11-01 17:49:10 +01:00
|
|
|
virtual TableBuilder *create_table(const String &name);
|
2021-11-14 13:56:25 +01:00
|
|
|
|
2021-11-01 17:49:10 +01:00
|
|
|
virtual TableBuilder *integer(const String &name);
|
2021-11-14 13:56:25 +01:00
|
|
|
virtual TableBuilder *integer(const String &name, const int length);
|
|
|
|
|
|
|
|
virtual TableBuilder *tiny_integer(const String &name);
|
|
|
|
virtual TableBuilder *tiny_integer(const String &name, const int length);
|
|
|
|
|
2021-11-14 16:52:09 +01:00
|
|
|
virtual TableBuilder *small_integer(const String &name);
|
|
|
|
virtual TableBuilder *small_integer(const String &name, const int length);
|
|
|
|
|
|
|
|
virtual TableBuilder *real_float(const String &name);
|
|
|
|
virtual TableBuilder *real_float(const String &name, const int size, const int d);
|
|
|
|
|
|
|
|
virtual TableBuilder *real_double(const String &name);
|
|
|
|
virtual TableBuilder *real_double(const String &name, const int size, const int d);
|
|
|
|
|
2021-11-01 17:49:10 +01:00
|
|
|
virtual TableBuilder *date(const String &name);
|
|
|
|
virtual TableBuilder *varchar(const String &name, const int length);
|
2020-12-01 23:37:10 +01:00
|
|
|
virtual TableBuilder *not_null();
|
|
|
|
virtual TableBuilder *null();
|
2021-11-14 13:56:25 +01:00
|
|
|
virtual TableBuilder *defval(const String &val);
|
2020-12-01 23:37:10 +01:00
|
|
|
virtual TableBuilder *auto_increment();
|
2021-11-01 17:49:10 +01:00
|
|
|
virtual TableBuilder *primary_key(const String &name);
|
2020-12-01 23:37:10 +01:00
|
|
|
virtual TableBuilder *primary_key();
|
|
|
|
virtual TableBuilder *next_row();
|
2021-08-19 23:55:16 +02:00
|
|
|
virtual TableBuilder *ccreate_table();
|
2020-12-01 23:37:10 +01:00
|
|
|
|
2021-08-19 23:55:16 +02:00
|
|
|
virtual TableBuilder *drop_table();
|
|
|
|
virtual TableBuilder *drop_table_if_exists();
|
2021-11-01 17:49:10 +01:00
|
|
|
virtual TableBuilder *drop_table(const String &name);
|
|
|
|
virtual TableBuilder *drop_table_if_exists(const String &name);
|
2021-08-19 23:55:16 +02:00
|
|
|
virtual TableBuilder *cdrop_table();
|
|
|
|
|
2021-11-01 17:49:10 +01:00
|
|
|
virtual TableBuilder *foreign_key(const String &name);
|
|
|
|
virtual TableBuilder *references(const String &table, const String &name);
|
2021-08-19 23:55:16 +02:00
|
|
|
|
2021-11-01 16:57:22 +01:00
|
|
|
virtual Ref<QueryResult> run();
|
2021-08-19 23:55:16 +02:00
|
|
|
virtual void run_query();
|
2020-12-02 00:49:17 +01:00
|
|
|
|
2021-08-19 23:55:16 +02:00
|
|
|
void print();
|
2020-12-01 23:37:10 +01:00
|
|
|
|
|
|
|
TableBuilder();
|
|
|
|
virtual ~TableBuilder();
|
|
|
|
|
2021-11-01 17:49:10 +01:00
|
|
|
String result;
|
2020-12-01 23:37:10 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|