@@ -65,7 +65,7 @@ test('bound command', function () {
65
65
66
66
test ( 'bind argument' , function ( ) {
67
67
assert . equal ( bindArg . statement , null )
68
- assert . equal ( bindArg . portal , null )
68
+ assert . equal ( bindArg . portal , '' )
69
69
assert . lengthIs ( bindArg . values , 1 )
70
70
assert . equal ( bindArg . values [ 0 ] , 'hi' )
71
71
} )
@@ -76,7 +76,7 @@ test('bound command', function () {
76
76
} )
77
77
78
78
test ( 'execute argument' , function ( ) {
79
- assert . equal ( executeArg . portal , null )
79
+ assert . equal ( executeArg . portal , '' )
80
80
assert . equal ( executeArg . rows , null )
81
81
} )
82
82
@@ -86,3 +86,70 @@ test('bound command', function () {
86
86
} )
87
87
} )
88
88
} )
89
+
90
+ var portalClient = helper . client ( )
91
+ var portalCon = portalClient . connection
92
+ var portalParseArg = null
93
+ portalCon . parse = function ( arg ) {
94
+ portalParseArg = arg
95
+ process . nextTick ( function ( ) {
96
+ portalCon . emit ( 'parseComplete' )
97
+ } )
98
+ }
99
+
100
+ var portalBindArg = null
101
+ portalCon . bind = function ( arg ) {
102
+ portalBindArg = arg
103
+ process . nextTick ( function ( ) {
104
+ portalCon . emit ( 'bindComplete' )
105
+ } )
106
+ }
107
+
108
+ var portalExecuteArg = null
109
+ portalCon . execute = function ( arg ) {
110
+ portalExecuteArg = arg
111
+ process . nextTick ( function ( ) {
112
+ portalCon . emit ( 'rowData' , { fields : [ ] } )
113
+ portalCon . emit ( 'commandComplete' , { text : '' } )
114
+ } )
115
+ }
116
+
117
+ var portalDescribeArg = null
118
+ portalCon . describe = function ( arg ) {
119
+ portalDescribeArg = arg
120
+ process . nextTick ( function ( ) {
121
+ portalCon . emit ( 'rowDescription' , { fields : [ ] } )
122
+ } )
123
+ }
124
+
125
+ portalCon . flush = function ( ) {
126
+ }
127
+ portalCon . sync = function ( ) {
128
+ process . nextTick ( function ( ) {
129
+ portalCon . emit ( 'readyForQuery' )
130
+ } )
131
+ }
132
+
133
+ test ( 'prepared statement with explicit portal' , function ( ) {
134
+ assert . ok ( portalClient . connection . emit ( 'readyForQuery' ) )
135
+
136
+ var query = portalClient . query ( new Query ( {
137
+ text : 'select * from X where name = $1' ,
138
+ portal : 'myportal' ,
139
+ values : [ 'hi' ]
140
+ } ) )
141
+
142
+ assert . emits ( query , 'end' , function ( ) {
143
+ test ( 'bind argument' , function ( ) {
144
+ assert . equal ( portalBindArg . portal , 'myportal' )
145
+ } )
146
+
147
+ test ( 'describe argument' , function ( ) {
148
+ assert . equal ( portalDescribeArg . name , 'myportal' )
149
+ } )
150
+
151
+ test ( 'execute argument' , function ( ) {
152
+ assert . equal ( portalExecuteArg . portal , 'myportal' )
153
+ } )
154
+ } )
155
+ } )
0 commit comments