From d7d307efa4a65d592893d303c9e10a3b86c4b0c4 Mon Sep 17 00:00:00 2001 From: SomaticIT Date: Tue, 16 Sep 2014 00:20:34 +0200 Subject: [PATCH 1/3] Update msnodesql definitions de 0.2.1 + generics --- msnodesql/msnodesql.d.ts | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/msnodesql/msnodesql.d.ts b/msnodesql/msnodesql.d.ts index 39bf01fb8..77ce4d389 100644 --- a/msnodesql/msnodesql.d.ts +++ b/msnodesql/msnodesql.d.ts @@ -1,6 +1,6 @@ -// Type definitions for msnodesql 0.2 +// Type definitions for msnodesql 0.2.1 // Project: https://github.com/WindowsAzure/node-sqlserver -// Definitions by: Boris Yankov +// Definitions by: Boris Yankov , Maxime LUCE // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -11,18 +11,25 @@ declare module "msnodesql" { export function open(connectionString: string, callback?: OpenCallback): Connection; - export function query(connectionString: string, query: string, callback?: QueryCallback): StreamEvents; - export function query(connectionString: string, query: string, params: any[], callback?: QueryCallback): StreamEvents; + export function query(connectionString: string, query: string): StreamEvents; + export function query(connectionString: string, query: string, callback: QueryCallback): StreamEvents; + export function query(connectionString: string, query: string, params: any[]): StreamEvents; + export function query(connectionString: string, query: string, params: any[], callback: QueryCallback): StreamEvents; - export function queryRaw(connectionString: string, query: string, callback?: QueryRawCallback): StreamEvents; - export function queryRaw(connectionString: string, query: string, params: any[], callback?: QueryRawCallback): StreamEvents; + export function query(connectionString: string, query: string, callback: QueryCallback): StreamEvents; + export function query(connectionString: string, query: string, params: any[], callback: QueryCallback): StreamEvents; + + export function queryRaw(connectionString: string, query: string): StreamEvents; + export function queryRaw(connectionString: string, query: string, callback: QueryRawCallback): StreamEvents; + export function queryRaw(connectionString: string, query: string, params: any[]): StreamEvents; + export function queryRaw(connectionString: string, query: string, params: any[], callback: QueryRawCallback): StreamEvents; interface OpenCallback { (err?: Error, connection?: Connection): void; } - interface QueryCallback { - (err?: Error, results?: QueryRawResult, more?: boolean): void; + interface QueryCallback { + (err?: Error, results?: T[], more?: boolean): void; } interface QueryRawCallback { @@ -43,11 +50,18 @@ declare module "msnodesql" { } interface Connection { - queryRaw(query: string, callback?: QueryCallback): StreamEvents; - queryRaw(query: string, params: any[], callback?: QueryCallback): StreamEvents; + query(query: string): StreamEvents; + query(query: string, callback: QueryCallback): StreamEvents; + query(query: string, params: any[]): StreamEvents; + query(query: string, params: any[], callback: QueryCallback): StreamEvents; - query(query: string, callback?: QueryRawCallback): StreamEvents; - query(query: string, params: any[], callback?: QueryRawCallback): StreamEvents; + query(query: string, callback: QueryCallback): StreamEvents; + query(query: string, params: any[], callback: QueryCallback): StreamEvents; + + queryRaw(query: string): StreamEvents; + queryRaw(query: string, callback: QueryRawCallback): StreamEvents; + queryRaw(query: string, params: any[]): StreamEvents; + queryRaw(query: string, params: any[], callback: QueryRawCallback): StreamEvents; beginTransaction(callback?: ErrorCallback); commit(callback?: ErrorCallback); From 692654726aa291688df3d05a07053719c3fd2734 Mon Sep 17 00:00:00 2001 From: SomaticIT Date: Tue, 16 Sep 2014 00:20:51 +0200 Subject: [PATCH 2/3] Add test for query callback --- msnodesql/msnodesql-tests.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/msnodesql/msnodesql-tests.ts b/msnodesql/msnodesql-tests.ts index 3f05f29aa..a27bf74e1 100644 --- a/msnodesql/msnodesql-tests.ts +++ b/msnodesql/msnodesql-tests.ts @@ -14,6 +14,22 @@ function test_streaming() { stmt.on('error', function (err) { console.log("We had an error :-( " + err); }); } +function test_callback() { + var conn_str = "Driver={SQL Server Native Client 11.0};Server={(local)\\SQLEXPRESS};Database={DBName};Trusted_Connection={Yes};"; + + sql.query(conn_str, "SELECT * FROM TestTable", (err, results) => { + if (err) { + console.error(err); + } + else if (results.length) { + console.log(results); + } + else { + console.log("No results"); + } + }); +} + function test_explicit() { var conn_str = "Driver={SQL Server Native Client 11.0};Server={(localdb)\\v11.0};Database={DBName};Trusted_Connection={Yes};"; From 4b57e494f7e2d2bab0b78c61323cc55effec86e6 Mon Sep 17 00:00:00 2001 From: SomaticIT Date: Tue, 16 Sep 2014 04:35:06 +0200 Subject: [PATCH 3/3] Fix contributors.md node-sqlserver was renamed msnodesql --- CONTRIBUTORS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index eb9f9b64e..e586cc1c7 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -264,6 +264,7 @@ All definitions files include a header with the author and editors, so at some p * [morgan](https://github.com/expressjs/morgan/) (by [James Roland Cabresos](https://github.com/staticfunction/)) * [Mousetrap](http://craig.is/killing/mice) (by [Dániel Tar](https://github.com/qcz)) * [msgpack.js](https://github.com/uupaa/msgpack.js) (by [Shinya Mochizuki](https://github.com/enrapt-mochizuki)) +* [msnodesql](https://github.com/WindowsAzure/node-sqlserver) (by [Boris Yankov](https://github.com/borisyankov) and [Maxime LUCE](https://github.com/SomaticIT)) * [Mustache.js](https://github.com/janl/mustache.js) (by [Boris Yankov](https://github.com/borisyankov)) * [mysql](https://github.com/felixge/node-mysql) (by [William Johnston](https://github.com/wjohnsto)) * [nconf](https://github.com/flatiron/nconf) (by [Jeff Goddard](https://github.com/jedigo)) @@ -275,9 +276,9 @@ All definitions files include a header with the author and editors, so at some p * [node-ffi](https://github.com/rbranson/node-ffi) (by [Paul Loyd](https://github.com/loyd)) * [node-form](https://github.com/rsamec/form) (by [Roman Samec](https://github.com/rsamec)) * [node-git](https://github.com/christkv/node-git) (by [vvakame](https://github.com/vvakame)) +* [node-sqlserver](https://github.com/WindowsAzure/node-sqlserver) (by [Boris Yankov](https://github.com/borisyankov) and [Maxime LUCE](https://github.com/SomaticIT)) * [nodeunit](https://github.com/caolan/nodeunit) (by [Jeff Goddard](https://github.com/jedigo)) * [node_zeromq](https://github.com/JustinTulloss/zeromq.node) (by [Dave McKeown](https://github.com/davemckeown)) -* [node-sqlserver](https://github.com/WindowsAzure/node-sqlserver) (by [Boris Yankov](https://github.com/borisyankov)) * [node-uuid](https://github.com/broofa/node-uuid) (by [Jeff May](https://github.com/jeffmay)) * [notify.js](https://github.com/alexgibson/notify.js) (by [soundTricker](https://github.com/soundTricker)) * [NProgress](https://github.com/rstacruz/nprogress) (by [Judah Gabriel Himango](https://github.com/judahgabriel))