File tree 2 files changed +29
-0
lines changed
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -103,3 +103,8 @@ QueryStream.prototype.handleCommandComplete = function(msg) {
103
103
QueryStream . prototype . handleReadyForQuery = function ( ) {
104
104
this . push ( null )
105
105
}
106
+
107
+ QueryStream . prototype . handleError = function ( err ) {
108
+ this . connection . sync ( )
109
+ this . emit ( 'error' , err )
110
+ }
Original file line number Diff line number Diff line change
1
+ var pg = require ( 'pg' )
2
+ var assert = require ( 'assert' )
3
+ var gonna = require ( 'gonna' )
4
+ var _ = require ( 'lodash' )
5
+ var concat = require ( 'concat-stream' )
6
+ var through = require ( 'through' )
7
+
8
+ var QueryStream = require ( '../' )
9
+
10
+ var client = new pg . Client ( )
11
+
12
+ var connected = gonna ( 'connect' , 100 , function ( ) {
13
+ var stream = new QueryStream ( 'SELECT * FROM asdf num' , [ ] )
14
+ var query = client . query ( stream )
15
+ query . on ( 'error' , gonna ( 'emit error' , 100 , function ( err ) {
16
+ assert ( err )
17
+ assert . equal ( err . code , '42P01' )
18
+ } ) )
19
+ var done = gonna ( 'keep connetion alive' , 100 )
20
+ client . query ( 'SELECT NOW()' , done )
21
+ } )
22
+
23
+ client . connect ( connected )
24
+ client . on ( 'drain' , client . end . bind ( client ) )
You can’t perform that action at this time.
0 commit comments