diff --git a/src/protocol.ts b/src/protocol.ts index b55e7e1..7cf8146 100644 --- a/src/protocol.ts +++ b/src/protocol.ts @@ -512,7 +512,9 @@ export function readRowData( offset += 4; - if (dimCount === 0) { + if (dimCount < 0) { + value = []; + } else if (dimCount === 0) { const size = buffer.readInt32BE(offset); offset += 8; value = readArray(size); diff --git a/test/result.test.ts b/test/result.test.ts index 37b06c9..86bd7fb 100644 --- a/test/result.test.ts +++ b/test/result.test.ts @@ -77,6 +77,11 @@ describe('Result', () => { deepEqual(row.a, [null]); }); + test('Parse empty array', async ({ client }) => { + const row = await client.query("select '{}'::text[] as a").one(); + deepEqual(row.a, []); + }); + test('Format array containing null value', async ({ client }) => { const row = await client .query('select $1::text[] as a', [[null]])