File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 1- module . exports = {
1+ var defaults = module . exports = {
22 // database host defaults to localhost
33 host : 'localhost' ,
44
@@ -38,3 +38,8 @@ module.exports = {
3838
3939 client_encoding : ""
4040} ;
41+
42+ //parse int8 so you can get your count values as actual numbers
43+ module . exports . __defineSetter__ ( "parseInt8" , function ( val ) {
44+ require ( './types' ) . setTypeParser ( 20 , 'text' , val ? parseInt : function ( val ) { return val ; } ) ;
45+ } ) ;
Original file line number Diff line number Diff line change 1+
2+ var helper = require ( __dirname + '/../test-helper' ) ;
3+ var pg = helper . pg ;
4+ test ( 'ability to turn on and off parser' , function ( ) {
5+ if ( helper . args . binary ) return false ;
6+ pg . connect ( helper . config , assert . success ( function ( client , done ) {
7+ pg . defaults . parseInt8 = true ;
8+ client . query ( 'CREATE TEMP TABLE asdf(id SERIAL PRIMARY KEY)' ) ;
9+ client . query ( 'SELECT COUNT(*) as "count" FROM asdf' , assert . success ( function ( res ) {
10+ pg . defaults . parseInt8 = false ;
11+ client . query ( 'SELECT COUNT(*) as "count" FROM asdf' , assert . success ( function ( res ) {
12+ done ( ) ;
13+ assert . strictEqual ( "0" , res . rows [ 0 ] . count ) ;
14+ pg . end ( ) ;
15+ } ) ) ;
16+ } ) ) ;
17+ } ) ) ;
18+ } ) ;
You can’t perform that action at this time.
0 commit comments