From 9067204979a9a2d5ab530504abc9b8d85aedc631 Mon Sep 17 00:00:00 2001 From: Aasim Khan Date: Fri, 2 Oct 2020 15:17:55 -0700 Subject: [PATCH] Aasim/release1.23/importfixes (#12721) * Fixing import getting stuck on step 4 (#12677) * Getting the proper attribute during column modification Exposing errors of change column settings and stopping import if they occur * removing extra space * Added a comment for error handling * Fixed a test error that was caused due to insufficient null checks. * removing unnecessary return * version bump of flat file services (#12686) --- extensions/import/config.json | 2 +- .../src/wizard/pages/modifyColumnsPage.ts | 8 +++--- .../import/src/wizard/pages/summaryPage.ts | 25 +++++++++++++------ 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/extensions/import/config.json b/extensions/import/config.json index e7b372c399..6bd2c02db6 100644 --- a/extensions/import/config.json +++ b/extensions/import/config.json @@ -1,7 +1,7 @@ { "downloadUrl": "https://sqlopsextensions.blob.core.windows.net/extensions/import/service/{#version#}/{#fileName#}", "useDefaultLinuxRuntime": true, - "version": "0.0.5", + "version": "0.0.6", "downloadFileNames": { "Windows_64": "win-x64.zip", "Windows_86": "win-x86.zip", diff --git a/extensions/import/src/wizard/pages/modifyColumnsPage.ts b/extensions/import/src/wizard/pages/modifyColumnsPage.ts index c3ec7c7618..690ff65ed9 100644 --- a/extensions/import/src/wizard/pages/modifyColumnsPage.ts +++ b/extensions/import/src/wizard/pages/modifyColumnsPage.ts @@ -96,10 +96,10 @@ export class ModifyColumnsPage extends ImportPage { this.model.proseColumns = []; this.table.data.forEach((row) => { this.model.proseColumns.push({ - columnName: row[0], - dataType: row[1], - primaryKey: row[2], - nullable: row[3] + columnName: row[0].value, + dataType: row[1].value, + primaryKey: row[2].value, + nullable: row[3].value }); }); }); diff --git a/extensions/import/src/wizard/pages/summaryPage.ts b/extensions/import/src/wizard/pages/summaryPage.ts index bfa369b976..29aef457f4 100644 --- a/extensions/import/src/wizard/pages/summaryPage.ts +++ b/extensions/import/src/wizard/pages/summaryPage.ts @@ -8,6 +8,7 @@ import * as azdata from 'azdata'; import { ImportPage } from '../api/importPage'; import { InsertDataResponse } from '../../services/contracts'; import * as constants from '../../common/constants'; +import { EOL } from 'os'; export class SummaryPage extends ImportPage { private _table: azdata.TableComponent; @@ -93,7 +94,7 @@ export class SummaryPage extends ImportPage { private populateTable() { this.table.updateProperties({ data: [ - [constants.serverNameText, this.model.server.providerName], + [constants.serverNameText, this.model.server.options.server], [constants.databaseText, this.model.database], [constants.tableNameText, this.model.table], [constants.tableSchemaText, this.model.schema], @@ -104,10 +105,9 @@ export class SummaryPage extends ImportPage { }); } - private async handleImport(): Promise { - let changeColumnResults = []; + private async handleImport(): Promise { let i = 0; - + const changeColumnSettingsErrors = []; for (let val of this.model.proseColumns) { let columnChangeParams = { index: i++, @@ -117,12 +117,24 @@ export class SummaryPage extends ImportPage { newInPrimaryKey: val.primaryKey }; const changeColumnResult = await this.provider.sendChangeColumnSettingsRequest(columnChangeParams); - changeColumnResults.push(changeColumnResult); + if (changeColumnResult?.result?.errorMessage) { + changeColumnSettingsErrors.push(changeColumnResult.result.errorMessage); + } + } + + // Stopping import if there are errors in change column setting. + if (changeColumnSettingsErrors.length !== 0) { + let updateText: string; + updateText = changeColumnSettingsErrors.join(EOL); + this.statusText.updateProperties({ + value: updateText + }); + return; } let result: InsertDataResponse; let err; - let includePasswordInConnectionString = (this.model.server.options.connectionId === 'Integrated') ? false : true; + let includePasswordInConnectionString = (this.model.server.options.authenticationType === 'Integrated') ? false : true; try { result = await this.provider.sendInsertDataRequest({ @@ -154,7 +166,6 @@ export class SummaryPage extends ImportPage { this.statusText.updateProperties({ value: updateText }); - return true; } // private async getCountRowsInserted(): Promise {