From 3645f6c5dbd946ba140d7b33950146356ccd3a26 Mon Sep 17 00:00:00 2001 From: Cahil Foley Date: Fri, 26 Jul 2019 02:36:01 +0800 Subject: [PATCH] [mssql] Fix incorrect Table and Request interfaces (#37123) * [mssql] align bulk method signatures with implementation * [mssql] add optional table path properties These properties go alongside the optional tableName parameter as per [this part of the table script](https://github.com/tediousjs/node-mssql/blob/6188de3a83c1ce55cf28c1c5875b4a5f7c636de6/lib/table.js#L10-L17) * [mssql] add optional temporary property to Table class --- types/mssql/index.d.ts | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/types/mssql/index.d.ts b/types/mssql/index.d.ts index 7ec471ede5..cd4f45815d 100644 --- a/types/mssql/index.d.ts +++ b/types/mssql/index.d.ts @@ -136,6 +136,11 @@ export interface IResult { rowsAffected: number[], output: { [key: string]: any }; } + +export interface IBulkResult { + rowsAffected: number; +} + export interface IProcedureResult extends IResult { returnValue: any; } @@ -246,6 +251,11 @@ export declare class Table { public columns: columns; public rows: rows; public constructor(tableName?: string); + public schema?: string; + public database?: string; + public name?: string; + public path?: string; + public temporary?: boolean; } interface IRequestParameters { @@ -261,6 +271,20 @@ interface IRequestParameters { } } +/** + * Options object to be passed through to driver (currently tedious only) + */ +export interface IBulkOptions { + /** Honors constraints during bulk load, using T-SQL CHECK_CONSTRAINTS. (default: false) */ + checkConstraints?: boolean; + /** Honors insert triggers during bulk load, using the T-SQL FIRE_TRIGGERS. (default: false) */ + fireTriggers?: boolean; + /** Honors null value passed, ignores the default values set on table, using T-SQL KEEP_NULLS. (default: false) */ + keepNulls?: boolean; + /** Places a bulk update(BU) lock on table while performing bulk load, using T-SQL TABLOCK. (default: false) */ + tableLock?: boolean; +} + export declare class Request extends events.EventEmitter { public transaction: Transaction; public pstatement: PreparedStatement; @@ -288,8 +312,10 @@ export declare class Request extends events.EventEmitter { public batch(batch: string): Promise>; public batch(batch: string, callback: (err?: Error, recordset?: IResult) => void): void; public batch(batch: string, callback: (err?: any, recordset?: IResult) => void): void; - public bulk(table: Table): Promise; - public bulk(table: Table, callback: (err: Error, rowCount: any) => void): void; + public bulk(table: Table): Promise; + public bulk(table: Table, options: IBulkOptions): Promise; + public bulk(table: Table, callback: (err: Error, result: IBulkResult) => void): void; + public bulk(table: Table, options: IBulkOptions, callback: (err: Error, result: IBulkResult) => void): void; public cancel(): void; public pause(): boolean; public resume(): boolean;