Skip to content

Commit 5845564

Browse files
Release v0.0.137
1 parent adbb3fe commit 5845564

File tree

6 files changed

+30
-7
lines changed

6 files changed

+30
-7
lines changed

dist/index.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -48417,13 +48417,21 @@ var SchemaDesigner = class {
4841748417
const targetCellState = this.currentState;
4841848418
if (targetCellState?.cell?.value) {
4841948419
const targetCellValue = targetCellState.cell.value;
48420+
const edgeBetweenSourceAndTarget = this.graph.model.getEdgesBetween(this.previous.cell, targetCellState.cell);
48421+
let existingForeignKey = void 0;
48422+
if (edgeBetweenSourceAndTarget.length > 0) {
48423+
existingForeignKey = edgeBetweenSourceAndTarget[0].value;
48424+
}
4842048425
if (cellValue) {
4842148426
const targetColumnName = targetCellValue.columns[this.currentRow - 1].name;
4842248427
cellValue.targetRow = this.currentRow;
4842348428
cellValue.referencedColumns = [targetColumnName];
4842448429
cellValue.referencedSchemaName = targetCellValue.schema;
4842548430
cellValue.referencedTableName = targetCellValue.name;
4842648431
cellValue.name = `FK_${sourceTableValue.name}_${cellValue.referencedTableName}`;
48432+
if (existingForeignKey !== void 0) {
48433+
cellValue.id = existingForeignKey.id;
48434+
}
4842748435
}
4842848436
}
4842948437
} else {
@@ -48482,7 +48490,6 @@ var SchemaDesigner = class {
4848248490
}
4848348491
const edgeState = this.edgeState;
4848448492
const edgeStateValue = edgeState.cell.value;
48485-
console.log(edgeStateValue.sourceRow, edgeStateValue.targetRow);
4848648493
const edgeBetweenSourceAndTarget = this.graph.model.getEdgesBetween(source, target);
4848748494
for (let i = 0; i < edgeBetweenSourceAndTarget.length; i++) {
4848848495
const edge = edgeBetweenSourceAndTarget[i];

dist/index.js.map

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/src/ts/schemaDesigner/schemaDesigner.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,22 @@ class SchemaDesigner {
326326
const targetCellState = this.currentState;
327327
if ((_a = targetCellState === null || targetCellState === void 0 ? void 0 : targetCellState.cell) === null || _a === void 0 ? void 0 : _a.value) {
328328
const targetCellValue = targetCellState.cell.value;
329+
// Existing foreign key between source and target
330+
const edgeBetweenSourceAndTarget = this.graph.model.getEdgesBetween(this.previous.cell, targetCellState.cell);
331+
let existingForeignKey = undefined;
332+
if (edgeBetweenSourceAndTarget.length > 0) {
333+
existingForeignKey = edgeBetweenSourceAndTarget[0].value;
334+
}
329335
if (cellValue) {
330336
const targetColumnName = targetCellValue.columns[this.currentRow - 1].name;
331337
cellValue.targetRow = this.currentRow;
332338
cellValue.referencedColumns = [targetColumnName];
333339
cellValue.referencedSchemaName = targetCellValue.schema;
334340
cellValue.referencedTableName = targetCellValue.name;
335341
cellValue.name = `FK_${sourceTableValue.name}_${cellValue.referencedTableName}`;
342+
if (existingForeignKey !== undefined) {
343+
cellValue.id = existingForeignKey.id;
344+
}
336345
}
337346
}
338347
}
@@ -394,7 +403,6 @@ class SchemaDesigner {
394403
}
395404
const edgeState = this.edgeState;
396405
const edgeStateValue = edgeState.cell.value;
397-
console.log(edgeStateValue.sourceRow, edgeStateValue.targetRow);
398406
const edgeBetweenSourceAndTarget = this.graph.model.getEdgesBetween(source, target);
399407
for (let i = 0; i < edgeBetweenSourceAndTarget.length; i++) {
400408
const edge = edgeBetweenSourceAndTarget[i];

dist/tsconfig.tsbuildinfo

+1-1
Large diffs are not rendered by default.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "azdataGraph",
33
"description": "azdataGraph is a derivative of mxGraph, which is a fully client side JavaScript diagramming library that uses SVG and HTML for rendering.",
4-
"version": "0.0.136",
4+
"version": "0.0.137",
55
"homepage": "https://github.com/microsoft/azdataGraph",
66
"author": "Microsoft",
77
"license": "Apache-2.0",

src/ts/schemaDesigner/schemaDesigner.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -354,13 +354,22 @@ export class SchemaDesigner {
354354
const targetCellState = (this as any).currentState as mxCellState;
355355
if (targetCellState?.cell?.value) {
356356
const targetCellValue = targetCellState.cell.value as SchemaDesignerTable;
357+
// Existing foreign key between source and target
358+
const edgeBetweenSourceAndTarget = this.graph.model.getEdgesBetween((this as any).previous.cell, targetCellState.cell);
359+
let existingForeignKey: EdgeCellValue | undefined = undefined;
360+
if (edgeBetweenSourceAndTarget.length > 0) {
361+
existingForeignKey = edgeBetweenSourceAndTarget[0].value as EdgeCellValue;
362+
}
357363
if (cellValue) {
358364
const targetColumnName = targetCellValue.columns[this.currentRow - 1].name;
359365
cellValue.targetRow = this.currentRow;
360366
cellValue.referencedColumns = [targetColumnName];
361367
cellValue.referencedSchemaName = targetCellValue.schema;
362368
cellValue.referencedTableName = targetCellValue.name;
363369
cellValue.name = `FK_${sourceTableValue.name}_${cellValue.referencedTableName}`;
370+
if (existingForeignKey !== undefined) {
371+
cellValue.id = existingForeignKey.id;
372+
}
364373
}
365374
}
366375
} else {
@@ -428,7 +437,6 @@ export class SchemaDesigner {
428437

429438
const edgeState = this.edgeState;
430439
const edgeStateValue = edgeState.cell.value as EdgeCellValue;
431-
console.log(edgeStateValue.sourceRow, edgeStateValue.targetRow);
432440
const edgeBetweenSourceAndTarget = this.graph.model.getEdgesBetween(source, target);
433441
for (let i = 0; i < edgeBetweenSourceAndTarget.length; i++) {
434442
const edge = edgeBetweenSourceAndTarget[i];

0 commit comments

Comments
 (0)