File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
packages/slonik/src/helpers.test Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -139,7 +139,7 @@ export const createIntegrationTests = (
139
139
await pool . end ( ) ;
140
140
} ) ;
141
141
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 ) => {
143
143
const pool = await createPool ( t . context . dsn , {
144
144
driverFactory,
145
145
} ) ;
@@ -153,6 +153,24 @@ export const createIntegrationTests = (
153
153
t . true ( error instanceof InvalidInputError ) ;
154
154
} ) ;
155
155
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
+
156
174
test ( 'NotNullIntegrityConstraintViolationError identifies the table and column' , async ( t ) => {
157
175
const pool = await createPool ( t . context . dsn , {
158
176
driverFactory,
You can’t perform that action at this time.
0 commit comments