File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 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 {
1616 this . handleReadyForQuery = this . cursor . handleReadyForQuery . bind ( this . cursor )
1717 this . handleError = this . cursor . handleError . bind ( this . cursor )
1818 this . handleEmptyQuery = this . cursor . handleEmptyQuery . bind ( this . cursor )
19+
20+ // pg client sets types via _result property
21+ this . _result = this . cursor . _result
1922 }
2023
2124 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