File tree 3 files changed +31
-6
lines changed
test/integration/gh-issues
3 files changed +31
-6
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,15 @@ Client.prototype.connect = function(callback) {
117
117
self . activeQuery . handleCommandComplete ( msg , con ) ;
118
118
} ) ;
119
119
120
+ //if a prepared statement has a name and properly parses
121
+ //we track that its already been executed so we don't parse
122
+ //it again on the same client
123
+ con . on ( 'parseComplete' , function ( msg ) {
124
+ if ( self . activeQuery . name ) {
125
+ con . parsedStatements [ self . activeQuery . name ] = true ;
126
+ }
127
+ } ) ;
128
+
120
129
con . on ( 'copyInResponse' , function ( msg ) {
121
130
self . activeQuery . handleCopyInResponse ( self . connection ) ;
122
131
} ) ;
Original file line number Diff line number Diff line change @@ -67,9 +67,6 @@ Query.prototype.handleDataRow = function(msg) {
67
67
} ;
68
68
69
69
Query . prototype . handleCommandComplete = function ( msg , con ) {
70
- if ( this . name ) {
71
- con . parsedStatements [ this . name ] = true ;
72
- }
73
70
this . _result . addCommandComplete ( msg ) ;
74
71
//need to sync after each command complete of a prepared statement
75
72
if ( this . isPreparedStatement ) {
Original file line number Diff line number Diff line change @@ -53,6 +53,25 @@ var steps = [
53
53
insertDataBar
54
54
]
55
55
56
- async . series ( steps , assert . success ( function ( ) {
57
- db . end ( )
58
- } ) )
56
+ test ( 'test if query fails' , function ( ) {
57
+ async . series ( steps , assert . success ( function ( ) {
58
+ db . end ( )
59
+ } ) )
60
+ } )
61
+
62
+ test ( 'test if prepare works but bind fails' , function ( ) {
63
+ var client = helper . client ( ) ;
64
+ var q = {
65
+ text : 'SELECT $1::int as name' ,
66
+ values : [ 'brian' ] ,
67
+ name : 'test'
68
+ } ;
69
+ client . query ( q , assert . calls ( function ( err , res ) {
70
+ q . values = [ 1 ] ;
71
+ client . query ( q , assert . calls ( function ( err , res ) {
72
+ assert . ifError ( err ) ;
73
+ client . end ( ) ;
74
+ } ) ) ;
75
+ } ) ) ;
76
+ } ) ;
77
+
You can’t perform that action at this time.
0 commit comments