Include field size in mssql export (#488)

This commit is contained in:
1ilit
2025-06-11 23:47:53 +04:00
committed by GitHub
parent 34a9b5f297
commit ba79c05b84

View File

@@ -36,7 +36,7 @@ export function toMSSQL(diagram) {
const fieldsSql = table.fields const fieldsSql = table.fields
.map( .map(
(field) => (field) =>
`\t[${field.name}] ${field.type}${ `\t[${field.name}] ${field.type}${field.size && `(${field.size})`}${
field.notNull ? " NOT NULL" : "" field.notNull ? " NOT NULL" : ""
}${field.increment ? " IDENTITY" : ""}${ }${field.increment ? " IDENTITY" : ""}${
field.unique ? " UNIQUE" : "" field.unique ? " UNIQUE" : ""
@@ -61,9 +61,7 @@ export function toMSSQL(diagram) {
.join(", ")})` .join(", ")})`
: ""; : "";
const createTableSql = `CREATE TABLE [${ const createTableSql = `CREATE TABLE [${table.name}] (\n${fieldsSql}${primaryKeySql}\n);\nGO\n`;
table.name
}] (\n${fieldsSql}${primaryKeySql}\n);\nGO\n`;
const tableCommentSql = generateAddExtendedPropertySQL( const tableCommentSql = generateAddExtendedPropertySQL(
table.comment, table.comment,
@@ -98,9 +96,7 @@ export function toMSSQL(diagram) {
if (!startTable || !endTable) return ""; if (!startTable || !endTable) return "";
const startField = startTable.fields.find( const startField = startTable.fields.find((f) => f.id === r.startFieldId);
(f) => f.id === r.startFieldId,
);
const endField = endTable.fields.find((f) => f.id === r.endFieldId); const endField = endTable.fields.find((f) => f.id === r.endFieldId);
if (!startField || !endField) return ""; if (!startField || !endField) return "";