@@ -218,17 +218,18 @@ export default function Postgres(url, options) {
218
218
}
219
219
}
220
220
221
- function array ( value , type ) {
221
+ function array ( value ) {
222
222
return {
223
- type,
223
+ type : inferType ( value ) ,
224
+ array : true ,
224
225
value
225
226
}
226
227
}
227
228
228
229
function json ( value ) {
229
230
return {
230
231
type : types . json . to ,
231
- value : types . json . serialize ( value )
232
+ value
232
233
}
233
234
}
234
235
@@ -249,11 +250,11 @@ export default function Postgres(url, options) {
249
250
250
251
function addArrayType ( oid , typelem ) {
251
252
const parser = options . parsers [ typelem ]
252
- , serializer = options . serializers [ typelem ]
253
+
253
254
typeArrayMap [ typelem ] = oid
254
255
options . parsers [ oid ] = ( xs ) => arrayParser ( xs , parser )
255
256
options . parsers [ oid ] . array = true
256
- options . serializers [ oid ] = ( xs ) => arraySerializer ( xs , serializer )
257
+ options . serializers [ oid ] = ( xs ) => arraySerializer ( xs , options . serializers [ typelem ] )
257
258
}
258
259
259
260
function addTypes ( instance , connection ) {
@@ -270,7 +271,7 @@ export default function Postgres(url, options) {
270
271
if ( name in instance )
271
272
throw errors . generic ( { message : name + ' is a reserved method name' , code : 'RESERVED_METHOD_NAME' } )
272
273
273
- instance [ name ] = ( x ) => ( { type : type . to , value : type . serializer ( x ) } )
274
+ instance [ name ] = ( x ) => ( { type : type . to , value : x } )
274
275
} )
275
276
}
276
277
@@ -371,14 +372,12 @@ export default function Postgres(url, options) {
371
372
}
372
373
373
374
function getType ( x ) {
374
- const value = x . value ? x . value : x
375
- , type = x . type || ( Array . isArray ( value ) ? typeArrayMap [ inferType ( value ) ] : inferType ( value ) )
375
+ const value = x . type ? x . value : x
376
+ , type = x && x . array ? typeArrayMap [ x . type || inferType ( value ) ] : ( x . type || inferType ( value ) )
376
377
377
378
return {
378
379
type,
379
- value : type
380
- ? ( options . serializers [ type ] || types . string . serialize ) ( value )
381
- : value
380
+ value : ( options . serializers [ type ] || types . string . serialize ) ( value )
382
381
}
383
382
}
384
383
}
0 commit comments