File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,8 +46,8 @@ p.connect = function() {
4646 } )
4747}
4848
49- p . query = function ( queryString ) {
50- var q = new NativeQuery ( queryString ) ;
49+ p . query = function ( config ) {
50+ var q = new NativeQuery ( config ) ;
5151 this . _queryQueue . push ( q ) ;
5252 this . _pulseQueryQueue ( ) ;
5353 return q ;
@@ -79,7 +79,7 @@ var ctor = function(config) {
7979 connection . _pulseQueryQueue ( ) ;
8080 } ) ;
8181
82- //proxy some events to active query
82+ //proxy some events to active query
8383 connection . on ( '_row' , function ( row ) {
8484 connection . _activeQuery . emit ( 'row' , row ) ;
8585 } )
@@ -108,7 +108,11 @@ var connect = function(config, callback) {
108108
109109//event emitter proxy
110110var NativeQuery = function ( text ) {
111- this . text = text ;
111+ if ( typeof text == 'object' ) {
112+ this . text = text . text ;
113+ } else {
114+ this . text = text ;
115+ }
112116 EventEmitter . call ( this ) ;
113117} ;
114118
Original file line number Diff line number Diff line change @@ -39,7 +39,18 @@ test('multiple results', function() {
3939 assert . equal ( row . name , 'Aaron' ) ;
4040 assert . emits ( q , 'row' , function ( row ) {
4141 assert . equal ( row . name , "Brian" ) ;
42- client . end ( ) ;
42+
43+ } )
44+ } )
45+ assert . emits ( q , 'end' , function ( ) {
46+ test ( 'query with config' , function ( ) {
47+ var q = client . query ( { text :'SELECT 1 as num' } ) ;
48+ assert . emits ( q , 'row' , function ( row ) {
49+ assert . strictEqual ( row . num , 1 ) ;
50+ assert . emits ( q , 'end' , function ( ) {
51+ client . end ( ) ;
52+ } )
53+ } )
4354 } )
4455 } )
4556 } )
You can’t perform that action at this time.
0 commit comments