summaryrefslogtreecommitdiffstats
path: root/Plugins/SqlEnterpriseFormatter/formataltertable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Plugins/SqlEnterpriseFormatter/formataltertable.cpp')
-rw-r--r--Plugins/SqlEnterpriseFormatter/formataltertable.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/Plugins/SqlEnterpriseFormatter/formataltertable.cpp b/Plugins/SqlEnterpriseFormatter/formataltertable.cpp
new file mode 100644
index 0000000..d562e1b
--- /dev/null
+++ b/Plugins/SqlEnterpriseFormatter/formataltertable.cpp
@@ -0,0 +1,31 @@
+#include "formataltertable.h"
+#include "parser/ast/sqlitealtertable.h"
+
+FormatAlterTable::FormatAlterTable(SqliteAlterTable* alterTable) :
+ alterTable(alterTable)
+{
+}
+
+void FormatAlterTable::formatInternal()
+{
+ withKeyword("ALTER").withKeyword("TABLE");
+
+ if (!alterTable->database.isNull())
+ withId(alterTable->database).withIdDot();
+
+ withId(alterTable->table);
+
+ if (alterTable->newColumn)
+ {
+ withKeyword("ADD");
+ if (alterTable->columnKw)
+ withKeyword("COLUMN");
+
+ withStatement(alterTable->newColumn);
+ }
+ else if (!alterTable->newName.isNull())
+ {
+ withKeyword("RENAME").withKeyword("TO").withId(alterTable->newName);
+ }
+ withSemicolon();
+}