diff --git a/core/database/table_builder.cpp b/core/database/table_builder.cpp index 4104a61..1ae2d95 100644 --- a/core/database/table_builder.cpp +++ b/core/database/table_builder.cpp @@ -10,6 +10,17 @@ TableBuilder *TableBuilder::integer(const String &name) { return this; } +TableBuilder *TableBuilder::integer(const String &name, const int length) { + return this; +} + +TableBuilder *TableBuilder::tiny_integer(const String &name) { + return this; +} +TableBuilder *TableBuilder::tiny_integer(const String &name, const int length) { + return this; +} + TableBuilder *TableBuilder::date(const String &name) { return this; } @@ -26,6 +37,10 @@ TableBuilder *TableBuilder::null() { return this; } +TableBuilder *TableBuilder::defval(const String &val) { + return this; +} + TableBuilder *TableBuilder::auto_increment() { return this; } diff --git a/core/database/table_builder.h b/core/database/table_builder.h index 914fe54..081ad57 100644 --- a/core/database/table_builder.h +++ b/core/database/table_builder.h @@ -10,11 +10,18 @@ class QueryResult; class TableBuilder : public Reference { public: virtual TableBuilder *create_table(const String &name); + virtual TableBuilder *integer(const String &name); + 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); + virtual TableBuilder *date(const String &name); virtual TableBuilder *varchar(const String &name, const int length); virtual TableBuilder *not_null(); virtual TableBuilder *null(); + virtual TableBuilder *defval(const String &val); virtual TableBuilder *auto_increment(); virtual TableBuilder *primary_key(const String &name); virtual TableBuilder *primary_key(); diff --git a/database/sqlite/sqlite3_table_builder.cpp b/database/sqlite/sqlite3_table_builder.cpp index 154eed3..435862a 100644 --- a/database/sqlite/sqlite3_table_builder.cpp +++ b/database/sqlite/sqlite3_table_builder.cpp @@ -13,6 +13,27 @@ TableBuilder *SQLite3TableBuilder::create_table(const String &name) { TableBuilder *SQLite3TableBuilder::integer(const String &name) { result += name + " INTEGER "; + return this; +} +TableBuilder *SQLite3TableBuilder::integer(const String &name, const int length) { + result += name + " INTEGER("; + result += String::num(length); + result += ") "; + + return this; +} + +TableBuilder *SQLite3TableBuilder::tiny_integer(const String &name) { + result += name + " INTEGER "; + + return this; +} +TableBuilder *SQLite3TableBuilder::tiny_integer(const String &name, const int length) { + result += name + " INTEGER("; + result += String::num(length); + result += ") "; + + return this; } @@ -40,6 +61,14 @@ TableBuilder *SQLite3TableBuilder::null() { return this; } +TableBuilder *SQLite3TableBuilder::defval(const String &val) { + result += "DEFAULT '"; + result += val; + result += "'"; + + return this; +} + TableBuilder *SQLite3TableBuilder::auto_increment() { //result += "AUTO_INCREMENT "; diff --git a/database/sqlite/sqlite3_table_builder.h b/database/sqlite/sqlite3_table_builder.h index a77a505..124fb24 100644 --- a/database/sqlite/sqlite3_table_builder.h +++ b/database/sqlite/sqlite3_table_builder.h @@ -10,11 +10,18 @@ class SQLite3Database; class SQLite3TableBuilder : public TableBuilder { public: TableBuilder *create_table(const String &name); + TableBuilder *integer(const String &name); + TableBuilder *integer(const String &name, const int length); + + TableBuilder *tiny_integer(const String &name); + TableBuilder *tiny_integer(const String &name, const int length); + TableBuilder *date(const String &name); TableBuilder *varchar(const String &name, const int length); TableBuilder *not_null(); TableBuilder *null(); + TableBuilder *defval(const String &val); TableBuilder *auto_increment(); TableBuilder *primary_key(const String &name); TableBuilder *primary_key();