Skip to content

Commit 4a5f5b1

Browse files
committed
test: ensure that json and jsonb are properly parsed by default
1 parent cb1e720 commit 4a5f5b1

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/postgres-bridge/bridge.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,40 @@ for (const {
287287
});
288288
});
289289

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+
290324
test(clientName + ': connection.query() interpolates parameters', async (t) => {
291325
const pool = new Pool({
292326
user: 'postgres',

0 commit comments

Comments
 (0)