@@ -4,7 +4,7 @@ import crypto from 'crypto'
4
4
import Stream from 'stream'
5
5
import { performance } from 'perf_hooks'
6
6
7
- import { stringify , handleValue , arrayParser , arraySerializer } from './types.js'
7
+ import { stringify , handleValue , arrayParser , arraySerializer , typesMapped } from './types.js'
8
8
import { Errors } from './errors.js'
9
9
import Result from './result.js'
10
10
import Queue from './queue.js'
@@ -183,13 +183,13 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
183
183
184
184
return q . options . simple
185
185
? b ( ) . Q ( ) . str ( q . statement . string + b . N ) . end ( )
186
- : q . describeFirst
186
+ : q . describeFirst
187
187
? Buffer . concat ( [ describe ( q ) , Flush ] )
188
- : q . prepare
189
- ? q . prepared
190
- ? prepared ( q )
191
- : Buffer . concat ( [ describe ( q ) , prepared ( q ) ] )
192
- : unnamed ( q )
188
+ : q . prepare
189
+ ? q . prepared
190
+ ? prepared ( q )
191
+ : Buffer . concat ( [ describe ( q ) , prepared ( q ) ] )
192
+ : unnamed ( q ) ;
193
193
}
194
194
195
195
function describe ( q ) {
@@ -230,11 +230,12 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
230
230
q . onlyDescribe && ( delete statements [ q . signature ] )
231
231
q . parameters = q . parameters || parameters
232
232
q . prepared = q . prepare && q . signature in statements
233
- q . describeFirst = q . onlyDescribe || ( parameters . length && ! q . prepared )
233
+ q . describeFirst = q . onlyDescribe || ( ! typesMapped ( q . args , types ) && ! q . prepared ) ;
234
234
q . statement = q . prepared
235
235
? statements [ q . signature ]
236
236
: { string, types, name : q . prepare ? statementId + statementCount ++ : '' }
237
237
238
+ console . log ( `types: ${ JSON . stringify ( types ) } ` )
238
239
typeof options . debug === 'function' && options . debug ( id , string , parameters , types )
239
240
}
240
241
@@ -602,8 +603,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
602
603
! query . statement . types [ i ] && ( query . statement . types [ i ] = x . readUInt32BE ( 7 + i * 4 ) )
603
604
604
605
query . prepare && ( statements [ query . signature ] = query . statement )
605
- query . describeFirst && ! query . onlyDescribe && ( write ( prepared ( query ) ) , query . describeFirst = false )
606
- }
606
+ query . describeFirst && ! query . onlyDescribe && write ( prepared ( query ) ) , ( query . describeFirst = false ) }
607
607
608
608
function RowDescription ( x ) {
609
609
if ( result . command ) {
@@ -951,7 +951,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
951
951
function Execute ( portal = '' , rows = 0 ) {
952
952
return Buffer . concat ( [
953
953
b ( ) . E ( ) . str ( portal + b . N ) . i32 ( rows ) . end ( ) ,
954
- Flush
954
+ rows != 0 ? Flush : Sync
955
955
] )
956
956
}
957
957
0 commit comments