From 54b12da33008952a6fbfccfd4c16219bce3b40a6 Mon Sep 17 00:00:00 2001 From: Alan Ren Date: Thu, 8 Jun 2023 15:06:23 -0700 Subject: [PATCH] add copy results to query provider (#23357) * add copy results to query provider * mark as optional * fix test stub * Update src/sql/azdata.proposed.d.ts Co-authored-by: Charles Gagnon * address comments * update return type --------- Co-authored-by: Charles Gagnon --- extensions/import/src/test/utils.test.ts | 3 ++ src/sql/azdata.proposed.d.ts | 49 +++++++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/extensions/import/src/test/utils.test.ts b/extensions/import/src/test/utils.test.ts index 820136d277..dee7eac482 100644 --- a/extensions/import/src/test/utils.test.ts +++ b/extensions/import/src/test/utils.test.ts @@ -78,6 +78,9 @@ export class TestQueryProvider implements azdata.QueryProvider { saveResults(requestParams: azdata.SaveResultsRequestParams): Thenable { throw new Error('Method not implemented.'); } + copyResults(requestParams: azdata.CopyResultsRequestParams): Thenable { + throw new Error('Method not implemented.'); + } setQueryExecutionOptions(ownerUri: string, options: azdata.QueryExecutionOptions): Thenable { throw new Error('Method not implemented.'); } diff --git a/src/sql/azdata.proposed.d.ts b/src/sql/azdata.proposed.d.ts index 3c8741351b..da30b5d850 100644 --- a/src/sql/azdata.proposed.d.ts +++ b/src/sql/azdata.proposed.d.ts @@ -823,11 +823,58 @@ declare module 'azdata' { parentTypeName?: string; } + /** + * Represents a selected range in the result grid. + */ + export interface SelectionRange { + fromRow: number; + toRow: number; + fromColumn: number; + toColumn: number; + } + + /** + * Parameters for the copy results request. + */ + export interface CopyResultsRequestParams { + /** + * URI of the editor. + */ + ownerUri: string; + /** + * Index of the batch. + */ + batchIndex: number; + /** + * Index of the result set. + */ + resultSetIndex: number; + /** + * Whether to include the column headers. + */ + includeHeaders: boolean + /** + * Whether to remove line breaks from the cell value. + */ + removeNewLines: boolean; + /** + * The selected ranges to be copied. + */ + selections: SelectionRange[]; + } + export interface QueryProvider { /** * Notify clients that the URI for a connection has been changed. */ - connectionUriChanged(newUri: string, oldUri: string): Thenable; + connectionUriChanged?(newUri: string, oldUri: string): Thenable; + /** + * Copy the selected data to the clipboard. + * This is introduced to address the performance issue of large amount of data to ADS side. + * ADS will use this if 'supportCopyResultsToClipboard' property is set to true in the provider contribution point in extension's package.json. + * Otherwise, The default handler will load all the selected data to ADS and perform the copy operation. + */ + copyResults?(requestParams: CopyResultsRequestParams): Thenable; } export enum DataProviderType {