Import Flat File Wizard - hangs at table schema (#10216)

* Using azure sql compatible query

* Included changes requested in PR for azure specific DBs and then fixed issue #9361 for contained databases.

* Made some changes mentioned in the PR
- Converted let to const
- Logging the error
This commit is contained in:
Aasim Khan
2020-05-01 10:53:02 -07:00
committed by GitHub
parent 8449888db8
commit 64c375a12d

View File

@@ -124,6 +124,9 @@ export class FileConfigPage extends ImportPage {
this.databaseDropdown.onValueChanged(async (db) => {
this.model.database = (<azdata.CategoryValue>this.databaseDropdown.value).name;
//this.populateTableNames();
let connectionProvider = azdata.dataprotocol.getProvider<azdata.ConnectionProvider>(this.model.server.providerName, azdata.DataProviderType.ConnectionProvider);
let connectionUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
connectionProvider.changeDatabase(connectionUri, this.model.database);
this.populateSchemaDropdown();
});
@@ -146,13 +149,25 @@ export class FileConfigPage extends ImportPage {
return false;
}
let values = await this.getDatabaseValues();
let defaultServerDatabase = this.model.server.options.database;
this.model.database = values[0].name;
let values: any[];
try {
values = await this.getDatabaseValues();
} catch (error) {
// This code is used in case of contained databases when the query will return an error.
console.log(error);
values = [{ displayName: defaultServerDatabase, name: defaultServerDatabase }];
this.databaseDropdown.editable = false;
}
this.model.database = defaultServerDatabase;
this.databaseDropdown.updateProperties({
values: values
});
this.databaseDropdown.value = { displayName: this.model.database, name: this.model.database };
this.databaseLoader.loading = false;
return true;
@@ -266,11 +281,11 @@ export class FileConfigPage extends ImportPage {
private async populateSchemaDropdown(): Promise<boolean> {
this.schemaLoader.loading = true;
let connectionUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
let queryProvider = azdata.dataprotocol.getProvider<azdata.QueryProvider>(this.model.server.providerName, azdata.DataProviderType.QueryProvider);
const escapedQuotedDb = this.databaseDropdown.value ? `[${(<azdata.CategoryValue>this.databaseDropdown.value).name.replace(/]/g, ']]')}].` : '';
const query = `SELECT name FROM ${escapedQuotedDb}sys.schemas`;
const query = `SELECT name FROM sys.schemas`;
let results = await queryProvider.runQueryAndReturn(connectionUri, query);