@@ -27,38 +27,37 @@ Connection.createQuery = function createQuery(sql, values, callback) {
27
27
return sql ;
28
28
}
29
29
30
- var cb = wrapCallbackInDomain ( null , callback ) ;
30
+ var cb = callback ;
31
31
var options = { } ;
32
32
33
33
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' ) {
39
36
for ( var prop in sql ) {
40
37
options [ prop ] = sql [ prop ] ;
41
38
}
42
39
43
40
if ( typeof values === 'function' ) {
44
- cb = wrapCallbackInDomain ( null , values ) ;
41
+ cb = values ;
45
42
} else if ( values !== undefined ) {
46
43
options . values = values ;
47
44
}
45
+ } else {
46
+ options . sql = sql ;
47
+ options . values = values ;
48
48
49
- return new Query ( options , cb ) ;
49
+ if ( typeof values === 'function' ) {
50
+ cb = values ;
51
+ options . values = undefined ;
52
+ }
50
53
}
51
54
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 ) ;
59
57
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
+ }
62
61
}
63
62
64
63
return new Query ( options , cb ) ;
0 commit comments