Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions test/result.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]])
Expand Down
Loading