File tree 2 files changed +30
-0
lines changed 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,9 @@ class PgQueryStream extends Readable {
16
16
this . handleReadyForQuery = this . cursor . handleReadyForQuery . bind ( this . cursor )
17
17
this . handleError = this . cursor . handleError . bind ( this . cursor )
18
18
this . handleEmptyQuery = this . cursor . handleEmptyQuery . bind ( this . cursor )
19
+
20
+ // pg client sets types via _result property
21
+ this . _result = this . cursor . _result
19
22
}
20
23
21
24
submit ( connection ) {
Original file line number Diff line number Diff line change
1
+ var pg = require ( 'pg' )
2
+ var assert = require ( 'assert' )
3
+ var QueryStream = require ( '../' )
4
+
5
+ describe ( 'client options' , function ( ) {
6
+ it ( 'uses custom types from client config' , function ( done ) {
7
+ const types = {
8
+ getTypeParser : ( ) => ( string ) => string ,
9
+ }
10
+ var client = new pg . Client ( { types } )
11
+ client . connect ( )
12
+ var stream = new QueryStream ( 'SELECT * FROM generate_series(0, 10) num' )
13
+ var query = client . query ( stream )
14
+ var result = [ ]
15
+ query . on ( 'data' , ( datum ) => {
16
+ result . push ( datum )
17
+ } )
18
+ query . on ( 'end' , ( ) => {
19
+ const expected = new Array ( 11 ) . fill ( 0 ) . map ( ( _ , i ) => ( {
20
+ num : i . toString ( ) ,
21
+ } ) )
22
+ assert . deepEqual ( result , expected )
23
+ client . end ( )
24
+ done ( )
25
+ } )
26
+ } )
27
+ } )
You can’t perform that action at this time.
0 commit comments