mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-13 17:22:15 -05:00
Correctly route notebook serialization requests to SQL Tools Service. (#20874)
This commit is contained in:
@@ -17,6 +17,10 @@ const saveAsNotSupported = localize('saveAsNotSupported', "Saving results into d
|
|||||||
const defaultBatchSize = 500;
|
const defaultBatchSize = 500;
|
||||||
|
|
||||||
export interface SerializeDataParams {
|
export interface SerializeDataParams {
|
||||||
|
/**
|
||||||
|
* The serializer to use for this request. Typically this is the ID of the connection provider used to run the query.
|
||||||
|
*/
|
||||||
|
serializationProviderId: string;
|
||||||
/**
|
/**
|
||||||
* 'csv', 'json', 'excel', 'xml'
|
* 'csv', 'json', 'excel', 'xml'
|
||||||
*/
|
*/
|
||||||
@@ -115,7 +119,13 @@ export class SerializationService implements ISerializationService {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// Create a new session with the provider and send initial data
|
// Create a new session with the provider and send initial data
|
||||||
let provider = this.providers[0].provider;
|
let provider = this.providers.find(provider => provider.providerId === serializationRequest.serializationProviderId)?.provider;
|
||||||
|
if (!provider) {
|
||||||
|
return <azdata.SerializeDataResult>{
|
||||||
|
messages: localize('missingSerializationProviderError', "Could not find a serialization provider with the specified ID '{0}'", serializationRequest.serializationProviderId),
|
||||||
|
succeeded: false
|
||||||
|
};
|
||||||
|
}
|
||||||
let index = 0;
|
let index = 0;
|
||||||
let startRequestParams = this.createStartRequest(serializationRequest, index);
|
let startRequestParams = this.createStartRequest(serializationRequest, index);
|
||||||
index = index + startRequestParams.rows.length;
|
index = index + startRequestParams.rows.length;
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import { getChartMaxRowCount, notifyMaxRowCountExceeded } from 'sql/workbench/co
|
|||||||
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
|
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
|
||||||
import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys';
|
import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys';
|
||||||
import { IExecutionPlanService } from 'sql/workbench/services/executionPlan/common/interfaces';
|
import { IExecutionPlanService } from 'sql/workbench/services/executionPlan/common/interfaces';
|
||||||
|
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: GridOutputComponent.SELECTOR,
|
selector: GridOutputComponent.SELECTOR,
|
||||||
@@ -487,8 +488,20 @@ export class DataResourceDataProvider implements IGridDataProvider {
|
|||||||
// interface than the query execution service's saveResults handlers. Here, we take the
|
// interface than the query execution service's saveResults handlers. Here, we take the
|
||||||
// format-specific request params (eg, includeHeaders for CSV) and merge the format-agnostic
|
// format-specific request params (eg, includeHeaders for CSV) and merge the format-agnostic
|
||||||
// request params for the serialization request (eg, saveFormat, filePath).
|
// request params for the serialization request (eg, saveFormat, filePath).
|
||||||
|
let provider = this.cellModel.notebookModel.context?.providerName;
|
||||||
|
if (!provider) {
|
||||||
|
// If no connection currently exists, then pick the first connection provider for the current kernel.
|
||||||
|
// If there's still no provider, then fallback to the default MSSQL one.
|
||||||
|
let connProviders = this.cellModel.notebookModel.getApplicableConnectionProviderIds(this.cellModel.notebookModel.selectedKernelDisplayName);
|
||||||
|
if (connProviders?.length > 0) {
|
||||||
|
provider = connProviders[0];
|
||||||
|
} else {
|
||||||
|
provider = mssqlProviderName;
|
||||||
|
}
|
||||||
|
}
|
||||||
let formatSpecificParams = serializer.getBasicSaveParameters(format);
|
let formatSpecificParams = serializer.getBasicSaveParameters(format);
|
||||||
let formatAgnosticParams = <Partial<SerializeDataParams>>{
|
let formatAgnosticParams = <Partial<SerializeDataParams>>{
|
||||||
|
serializationProviderId: provider,
|
||||||
saveFormat: format,
|
saveFormat: format,
|
||||||
filePath: filePath.fsPath,
|
filePath: filePath.fsPath,
|
||||||
columns: columns,
|
columns: columns,
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ suite('Data Resource Data Provider', function () {
|
|||||||
fileDialogService = new TestFileDialogService(pathService);
|
fileDialogService = new TestFileDialogService(pathService);
|
||||||
notificationService = new TestNotificationService();
|
notificationService = new TestNotificationService();
|
||||||
serializationService = new SerializationService(undefined, undefined); //_connectionService _capabilitiesService
|
serializationService = new SerializationService(undefined, undefined); //_connectionService _capabilitiesService
|
||||||
serializationService.registerProvider('testProviderId', new TestSerializationProvider());
|
serializationService.registerProvider('MSSQL', new TestSerializationProvider());
|
||||||
serializer = new ResultSerializer(
|
serializer = new ResultSerializer(
|
||||||
undefined, // IQueryManagementService
|
undefined, // IQueryManagementService
|
||||||
undefined, // IConfigurationService
|
undefined, // IConfigurationService
|
||||||
|
|||||||
Reference in New Issue
Block a user