File tree 2 files changed +24
-1
lines changed
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 = {
2
2
// database host defaults to localhost
3
3
host : 'localhost' ,
4
4
@@ -38,3 +38,8 @@ module.exports = {
38
38
39
39
client_encoding : ""
40
40
} ;
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