Skip to content

Free, simple, and intuitive online database diagram editor and SQL generator.

Skip fieldless custom types when exporting to SQL Server (#1146)

Ngo Quoc Viet1e6349ec9869
diff --git a/src/utils/exportSQL/generic.js b/src/utils/exportSQL/generic.js
index f83890bf..2bcaf9aa 100644
--- a/src/utils/exportSQL/generic.js
+++ b/src/utils/exportSQL/generic.js
@@ -524,14 +524,16 @@ function tablesToMariaDB(obj) {
function tablesToSQLServer(obj) {
return `${obj.types
+ .filter((type) => type.fields.length > 0)
.map((type) => {
return `${
type.comment === "" ? "" : `/**\n${type.comment}\n*/\n`
- }CREATE TYPE [${type.name}] FROM ${
- type.fields.length < 0
- ? ""
- : `${getTypeString(type.fields[0], obj.database, DB.MSSQL, true)}`
- };\nGO\n`;
+ }CREATE TYPE [${type.name}] FROM ${getTypeString(
+ type.fields[0],
+ obj.database,
+ DB.MSSQL,
+ true,
+ )};\nGO\n`;
})
.join("\n")}\n${obj.tables
.map(