@@ -199,7 +199,7 @@ function Postgres(a, b) {
199
199
function nested ( first , rest ) {
200
200
const o = Object . create ( notPromise )
201
201
o . first = first
202
- o . rest = rest
202
+ o . rest = rest . flat ( )
203
203
return o
204
204
}
205
205
@@ -222,12 +222,10 @@ function Postgres(a, b) {
222
222
return connection
223
223
}
224
224
225
- function array ( value ) {
226
- return {
227
- type : inferType ( value ) || 25 ,
228
- array : true ,
229
- value
230
- }
225
+ function array ( xs ) {
226
+ const o = Object . create ( notPromise )
227
+ o . array = xs
228
+ return o
231
229
}
232
230
233
231
function json ( value ) {
@@ -395,10 +393,7 @@ function Postgres(a, b) {
395
393
396
394
for ( let i = 1 ; i < xs . length ; i ++ ) {
397
395
arg = args [ i - 1 ]
398
- str += ( arg && arg . P === notPromise . P
399
- ? parseHelper ( str , arg , xargs , types )
400
- : parseValue ( arg , xargs , types )
401
- ) + xs [ i ]
396
+ str += parseArg ( str , arg , xargs , types ) + xs [ i ]
402
397
}
403
398
404
399
return {
@@ -408,6 +403,21 @@ function Postgres(a, b) {
408
403
}
409
404
}
410
405
406
+ function parseArg ( str , arg , xargs , types ) {
407
+ return arg && arg . P === notPromise . P
408
+ ? arg . array
409
+ ? parseArray ( arg . array , xargs , types )
410
+ : parseHelper ( str , arg , xargs , types )
411
+ : parseValue ( arg , xargs , types )
412
+ }
413
+
414
+ function parseArray ( array , xargs , types ) {
415
+ return array . length === 0 ? '\'{}\'' : 'array[' + array . map ( ( x ) => Array . isArray ( x )
416
+ ? parseArray ( x , xargs , types )
417
+ : parseValue ( x , xargs , types )
418
+ ) . join ( ',' ) + ']'
419
+ }
420
+
411
421
function parseHelper ( str , { first, rest } , xargs , types ) {
412
422
xargs . dynamic = true
413
423
if ( first !== null && typeof first === 'object' && typeof first [ 0 ] !== 'string' ) {
@@ -458,6 +468,8 @@ function Postgres(a, b) {
458
468
459
469
return Array . isArray ( x )
460
470
? x . reduce ( ( acc , x ) => acc + ( acc ? ',' : '' ) + addValue ( x , xargs , types ) , '' )
471
+ : x && x . P === notPromise . P
472
+ ? parseArg ( '' , x , xargs , types )
461
473
: addValue ( x , xargs , types )
462
474
}
463
475
@@ -477,7 +489,7 @@ function Postgres(a, b) {
477
489
return { type : 0 , value : x }
478
490
479
491
const value = x . type ? x . value : x
480
- , type = x . array ? typeArrayMap [ x . type ] : ( x . type || inferType ( value ) )
492
+ , type = x . type || inferType ( value )
481
493
482
494
return {
483
495
type,
0 commit comments