aboutsummaryrefslogtreecommitdiffstats
path: root/Plugins/SqlEnterpriseFormatter/formatcreatetable.cpp
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2021-12-17 07:07:47 -0500
committerLibravatarUnit 193 <unit193@unit193.net>2021-12-17 07:07:47 -0500
commit558b1e35fd0777ac97763c1b28056ac984e583e7 (patch)
tree1eb2557119a117ea76535c89cd14a49e510b96bf /Plugins/SqlEnterpriseFormatter/formatcreatetable.cpp
parentc22eb635c11fd45f9c30f911d70e1d79111a49ce (diff)
parent1fdc150116cad39aae5c5da407c3312b47a59e3a (diff)
Update upstream source from tag 'upstream/3.3.3+dfsg1'
Update to upstream version '3.3.3+dfsg1' with Debian dir 9a301fff4922aed2fec0c04c7d011947168c42f1
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: