File tree Expand file tree Collapse file tree 3 files changed +31
-6
lines changed
test/integration/gh-issues Expand file tree Collapse file tree 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) {
117117 self . activeQuery . handleCommandComplete ( msg , con ) ;
118118 } ) ;
119119
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+
120129 con . on ( 'copyInResponse' , function ( msg ) {
121130 self . activeQuery . handleCopyInResponse ( self . connection ) ;
122131 } ) ;
Original file line number Diff line number Diff line change @@ -67,9 +67,6 @@ Query.prototype.handleDataRow = function(msg) {
6767} ;
6868
6969Query . prototype . handleCommandComplete = function ( msg , con ) {
70- if ( this . name ) {
71- con . parsedStatements [ this . name ] = true ;
72- }
7370 this . _result . addCommandComplete ( msg ) ;
7471 //need to sync after each command complete of a prepared statement
7572 if ( this . isPreparedStatement ) {
Original file line number Diff line number Diff line change @@ -53,6 +53,25 @@ var steps = [
5353 insertDataBar
5454]
5555
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