Different arguments for new Request

Request can be constructed with a connection, preparedStatment,
transaction or no arguments
This commit is contained in:
Ben Farr
2015-09-13 21:49:01 +01:00
parent 5ac3ef67ba
commit 1ae80ee1ef
2 changed files with 29 additions and 14 deletions
+13
View File
@@ -113,3 +113,16 @@ function test_promise_returns() {
request.query('SELECT 1').then((recordset) => { });
request.execute('procedure_name').then((recordset) => { });
}
function test_request_constructor() {
// Request can be constructed with a connection, preparedStatment, transaction or no arguments
var connection: sql.Connection = new sql.Connection(config);
var preparedStatment = new sql.PreparedStatement(connection);
var transaction = new sql.Transaction(connection);
var request1 = new sql.Request(connection);
var request2 = new sql.Request(preparedStatment);
var request3 = new sql.Request(transaction);
var request4 = new sql.Request();
}
+16 -14
View File
@@ -117,20 +117,22 @@ declare module "mssql" {
export class Request {
public constructor(connection?: Connection);
public pipe(stream: any): void;
execute(procedure: string): Promise<recordSet>;
execute(procedure: string, callback: (err?: any, recordsets?: any, returnValue?: any) => void): void;
input(name: string, value: any): void;
input(name: string, type: any, value: any): void;
output(name: string, type: any, value?: any): void;
query(command: string): Promise<void>;
query(command: string, callback: (err?: any, recordset?: any) => void): void;
batch(batch: string): Promise<recordSet>;
batch(batch: string, callback: (err?: any, recordset?: any) => void): void;
bulk(table: Table): Promise<void>;
bulk(table: Table, callback: (err: any, rowCount: any) => void): void;
cancel(): void;
parameters: any;
public constructor(transaction: Transaction);
public constructor(preparedStatement: PreparedStatement);
public execute(procedure: string): Promise<recordSet>;
public execute(procedure: string, callback: (err?: any, recordsets?: any, returnValue?: any) => void): void;
public input(name: string, value: any): void;
public input(name: string, type: any, value: any): void;
public output(name: string, type: any, value?: any): void;
public pipe(stream: NodeJS.WritableStream): void;
public query(command: string): Promise<void>;
public query(command: string, callback: (err?: any, recordset?: any) => void): void;
public batch(batch: string): Promise<recordSet>;
public batch(batch: string, callback: (err?: any, recordset?: any) => void): void;
public bulk(table: Table): Promise<void>;
public bulk(table: Table, callback: (err: any, rowCount: any) => void): void;
public cancel(): void;
public parameters: any;
}
export class Transaction {