Skip to content

Commit ee7d485

Browse files
committed
test: test int4 and int4[] return types
1 parent cb7fbf9 commit ee7d485

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

test/postgres-bridge/bridge.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,25 +151,49 @@ for (const {
151151
t.is(pool.idleCount, 1);
152152
});
153153

154-
test(clientName + ': connection.query() returns expected results', async (t) => {
154+
test(clientName + ': connection.query() returns integers', async (t) => {
155155
const pool = new Pool({
156156
user: 'postgres',
157157
});
158158

159159
const connection = await pool.connect();
160160

161-
const result = await connection.query('SELECT 1');
161+
const result = await connection.query('SELECT 1::int4 AS foo');
162162

163163
t.is(result.rows.length, 1);
164164
t.is(result.command, 'SELECT');
165165
t.like(result.rows[0],
166166
{
167-
'?column?': 1,
167+
foo: 1,
168168
});
169169
t.like(result.fields[0],
170170
{
171171
dataTypeID: 23,
172-
name: '?column?',
172+
name: 'foo',
173+
});
174+
});
175+
176+
test(clientName + ': connection.query() returns integer arrays', async (t) => {
177+
const pool = new Pool({
178+
user: 'postgres',
179+
});
180+
181+
const connection = await pool.connect();
182+
183+
const result = await connection.query('SELECT ARRAY[1]::int4[] AS foo');
184+
185+
t.is(result.rows.length, 1);
186+
t.is(result.command, 'SELECT');
187+
t.like(result.rows[0],
188+
{
189+
foo: [
190+
1,
191+
],
192+
});
193+
t.like(result.fields[0],
194+
{
195+
dataTypeID: 1_007,
196+
name: 'foo',
173197
});
174198
});
175199

0 commit comments

Comments
 (0)