mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 11:01:37 -05:00
fix schema compare diff script formatting (#5486)
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/v{#version#}/microsoft.sqltools.servicelayer-{#fileName#}",
|
"downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/v{#version#}/microsoft.sqltools.servicelayer-{#fileName#}",
|
||||||
"version": "1.5.0-alpha.91",
|
"version": "1.5.0-alpha.93",
|
||||||
"downloadFileNames": {
|
"downloadFileNames": {
|
||||||
"Windows_86": "win-x86-netcoreapp2.2.zip",
|
"Windows_86": "win-x86-netcoreapp2.2.zip",
|
||||||
"Windows_64": "win-x64-netcoreapp2.2.zip",
|
"Windows_64": "win-x64-netcoreapp2.2.zip",
|
||||||
|
|||||||
@@ -237,8 +237,8 @@ export class SchemaCompareResult {
|
|||||||
this.differencesTable.onRowSelected(() => {
|
this.differencesTable.onRowSelected(() => {
|
||||||
let difference = this.comparisonResult.differences[this.differencesTable.selectedRows[0]];
|
let difference = this.comparisonResult.differences[this.differencesTable.selectedRows[0]];
|
||||||
if (difference !== undefined) {
|
if (difference !== undefined) {
|
||||||
sourceText = difference.sourceScript === null ? '\n' : this.getAggregatedScript(difference, true);
|
sourceText = this.getFormattedScript(difference, true);
|
||||||
targetText = difference.targetScript === null ? '\n' : this.getAggregatedScript(difference, false);
|
targetText = this.getFormattedScript(difference, false);
|
||||||
|
|
||||||
this.diffEditor.updateProperties({
|
this.diffEditor.updateProperties({
|
||||||
contentLeft: sourceText,
|
contentLeft: sourceText,
|
||||||
@@ -264,15 +264,29 @@ export class SchemaCompareResult {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getFormattedScript(diffEntry: azdata.DiffEntry, getSourceScript: boolean): string {
|
||||||
|
// if there is no entry, the script has to be \n because an empty string shows up as a difference but \n doesn't
|
||||||
|
if ((getSourceScript && diffEntry.sourceScript === null)
|
||||||
|
|| (!getSourceScript && diffEntry.targetScript === null)) {
|
||||||
|
return '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
let script = this.getAggregatedScript(diffEntry, getSourceScript);
|
||||||
|
return script;
|
||||||
|
}
|
||||||
|
|
||||||
private getAggregatedScript(diffEntry: azdata.DiffEntry, getSourceScript: boolean): string {
|
private getAggregatedScript(diffEntry: azdata.DiffEntry, getSourceScript: boolean): string {
|
||||||
let script = '';
|
let script = '';
|
||||||
if (diffEntry !== null) {
|
if (diffEntry !== null) {
|
||||||
script += getSourceScript ? diffEntry.sourceScript : diffEntry.targetScript;
|
let diffEntryScript = getSourceScript ? diffEntry.sourceScript : diffEntry.targetScript;
|
||||||
|
if (diffEntryScript) {
|
||||||
|
// add a blank line between each statement
|
||||||
|
script += diffEntryScript + '\n\n';
|
||||||
|
}
|
||||||
|
|
||||||
diffEntry.children.forEach(child => {
|
diffEntry.children.forEach(child => {
|
||||||
let childScript = this.getAggregatedScript(child, getSourceScript);
|
let childScript = this.getAggregatedScript(child, getSourceScript);
|
||||||
if (childScript !== 'null') {
|
|
||||||
script += childScript;
|
script += childScript;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return script;
|
return script;
|
||||||
|
|||||||
Reference in New Issue
Block a user