Skip to content

Commit 75f6518

Browse files
committed
wip
1 parent 9fdc0fd commit 75f6518

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

packages/slonik/src/helpers.test/createIntegrationTests.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export const createIntegrationTests = (
139139
await pool.end();
140140
});
141141

142-
test('produces error if multiple statements are passed as the query input', async (t) => {
142+
test('produces error if multiple statements are passed as the query input (without parameters)', async (t) => {
143143
const pool = await createPool(t.context.dsn, {
144144
driverFactory,
145145
});
@@ -153,6 +153,24 @@ export const createIntegrationTests = (
153153
t.true(error instanceof InvalidInputError);
154154
});
155155

156+
// The difference between this test and the previous one is that this one is expected to fail before the query is executed.
157+
// In case of pg driver, that is because of the { queryMode: 'extended' } setting.
158+
test('produces error if multiple statements are passed as the query input (with parameters)', async (t) => {
159+
const pool = await createPool(t.context.dsn, {
160+
driverFactory,
161+
});
162+
163+
const error = await t.throwsAsync(
164+
pool.query(sql.unsafe`
165+
SELECT ${1}; SELECT ${2};
166+
`),
167+
);
168+
169+
// The actual error is going to be driver specific, e.g.: 'cannot insert multiple commands into a prepared statement'.
170+
// However, Slonik will require compatible drivers to throw InputSyntaxError.
171+
t.true(error instanceof InputSyntaxError);
172+
});
173+
156174
test('NotNullIntegrityConstraintViolationError identifies the table and column', async (t) => {
157175
const pool = await createPool(t.context.dsn, {
158176
driverFactory,

0 commit comments

Comments
 (0)