File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -287,6 +287,40 @@ for (const {
287
287
} ) ;
288
288
} ) ;
289
289
290
+ test ( clientName + ': connection.query() parses json' , async ( t ) => {
291
+ const pool = new Pool ( {
292
+ user : 'postgres' ,
293
+ } ) ;
294
+
295
+ const connection = await pool . connect ( ) ;
296
+
297
+ const result = await connection . query ( 'SELECT \'{"bar":"baz"}\'::json AS foo' ) ;
298
+
299
+ t . like ( result . rows [ 0 ] ,
300
+ {
301
+ foo : {
302
+ bar : 'baz' ,
303
+ } ,
304
+ } ) ;
305
+ } ) ;
306
+
307
+ test ( clientName + ': connection.query() parses jsonb' , async ( t ) => {
308
+ const pool = new Pool ( {
309
+ user : 'postgres' ,
310
+ } ) ;
311
+
312
+ const connection = await pool . connect ( ) ;
313
+
314
+ const result = await connection . query ( 'SELECT \'{"bar":"baz"}\'::jsonb AS foo' ) ;
315
+
316
+ t . like ( result . rows [ 0 ] ,
317
+ {
318
+ foo : {
319
+ bar : 'baz' ,
320
+ } ,
321
+ } ) ;
322
+ } ) ;
323
+
290
324
test ( clientName + ': connection.query() interpolates parameters' , async ( t ) => {
291
325
const pool = new Pool ( {
292
326
user : 'postgres' ,
You can’t perform that action at this time.
0 commit comments