aboutsummaryrefslogtreecommitdiffstats
path: root/Plugins/SqlEnterpriseFormatter/formatcreatetable.cpp
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2021-12-17 07:06:30 -0500
committerLibravatarUnit 193 <unit193@unit193.net>2021-12-17 07:06:30 -0500
commit1fdc150116cad39aae5c5da407c3312b47a59e3a (patch)
tree123c79a4d7ad2d45781ba03ce939f7539fb428d8 /Plugins/SqlEnterpriseFormatter/formatcreatetable.cpp
parentfeda8a7db8d1d7c5439aa8f8feef7cc0dd2b59a0 (diff)
New upstream version 3.3.3+dfsg1.upstream/3.3.3+dfsg1
Diffstat (limited to 'Plugins/SqlEnterpriseFormatter/formatcreatetable.cpp')
-rw-r--r--Plugins/SqlEnterpriseFormatter/formatcreatetable.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/Plugins/SqlEnterpriseFormatter/formatcreatetable.cpp b/Plugins/SqlEnterpriseFormatter/formatcreatetable.cpp
index 6ac6226..e6fd189 100644
--- a/Plugins/SqlEnterpriseFormatter/formatcreatetable.cpp
+++ b/Plugins/SqlEnterpriseFormatter/formatcreatetable.cpp
@@ -20,7 +20,7 @@ void FormatCreateTable::formatInternal()
if (createTable->ifNotExistsKw)
withKeyword("IF").withKeyword("NOT").withKeyword("EXISTS");
- if (dialect == Dialect::Sqlite3 && !createTable->database.isNull())
+ if (!createTable->database.isNull())
withId(createTable->database).withIdDot();
withId(createTable->table);
@@ -81,9 +81,9 @@ void FormatCreateTable::formatColumns(const QList<SqliteCreateTable::Column*>& c
int FormatCreateTable::getColNameLength(const QString& name)
{
if (cfg->SqlEnterpriseFormatter.AlwaysUseNameWrapping.get())
- return wrapObjName(name, dialect, wrapper).length();
+ return wrapObjName(name, wrapper).length();
else
- return wrapObjIfNeeded(name, dialect, wrapper).length();
+ return wrapObjIfNeeded(name, wrapper).length();
}
FormatCreateTableColumn::FormatCreateTableColumn(SqliteCreateTable::Column* column) :
@@ -173,6 +173,17 @@ void FormatCreateTableColumnConstraint::formatInternal()
withStatement(constr->foreignKey);
break;
}
+ case SqliteCreateTable::Column::Constraint::GENERATED:
+ {
+ if (constr->generatedKw)
+ withKeyword("GENERATED").withKeyword("ALWAYS");
+
+ withKeyword("AS").withParExprLeft().withStatement(constr->expr).withParExprRight();
+ if (constr->generatedType != SqliteCreateTable::Column::Constraint::GeneratedType::null)
+ withId(SqliteCreateTable::Column::Constraint::toString(constr->generatedType), false);
+
+ break;
+ }
case SqliteCreateTable::Column::Constraint::NULL_:
case SqliteCreateTable::Column::Constraint::NAME_ONLY:
case SqliteCreateTable::Column::Constraint::DEFERRABLE_ONLY: