@@ -27,38 +27,37 @@ Connection.createQuery = function createQuery(sql, values, callback) {
2727 return sql ;
2828 }
2929
30- var cb = wrapCallbackInDomain ( null , callback ) ;
30+ var cb = callback ;
3131 var options = { } ;
3232
3333 if ( typeof sql === 'function' ) {
34- cb = wrapCallbackInDomain ( null , sql ) ;
35- return new Query ( options , cb ) ;
36- }
37-
38- if ( typeof sql === 'object' ) {
34+ cb = sql ;
35+ } else if ( typeof sql === 'object' ) {
3936 for ( var prop in sql ) {
4037 options [ prop ] = sql [ prop ] ;
4138 }
4239
4340 if ( typeof values === 'function' ) {
44- cb = wrapCallbackInDomain ( null , values ) ;
41+ cb = values ;
4542 } else if ( values !== undefined ) {
4643 options . values = values ;
4744 }
45+ } else {
46+ options . sql = sql ;
47+ options . values = values ;
4848
49- return new Query ( options , cb ) ;
49+ if ( typeof values === 'function' ) {
50+ cb = values ;
51+ options . values = undefined ;
52+ }
5053 }
5154
52- options . sql = sql ;
53- options . values = values ;
54-
55- if ( typeof values === 'function' ) {
56- cb = wrapCallbackInDomain ( null , values ) ;
57- options . values = undefined ;
58- }
55+ if ( cb !== undefined ) {
56+ cb = wrapCallbackInDomain ( null , cb ) ;
5957
60- if ( cb === undefined && callback !== undefined ) {
61- throw new TypeError ( 'argument callback must be a function when provided' ) ;
58+ if ( cb === undefined ) {
59+ throw new TypeError ( 'argument callback must be a function when provided' ) ;
60+ }
6261 }
6362
6463 return new Query ( options , cb ) ;
0 commit comments