@contember/database 2.2.0-alpha.17 → 2.2.0-alpha.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +1 -1
- package/dist/development/index.cjs +1 -0
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +2 -1
- package/dist/development/src/client/AcquiredConnection.cjs +2 -0
- package/dist/development/src/client/AcquiredConnection.cjs.map +1 -1
- package/dist/development/src/client/AcquiredConnection.js +3 -1
- package/dist/development/src/client/AcquiredConnection.js.map +1 -1
- package/dist/development/src/client/errors.cjs +6 -1
- package/dist/development/src/client/errors.cjs.map +1 -1
- package/dist/development/src/client/errors.js +6 -1
- package/dist/development/src/client/errors.js.map +1 -1
- package/dist/development/src/utils/pgClientFactory.cjs.map +1 -1
- package/dist/development/src/utils/pgClientFactory.js.map +1 -1
- package/dist/production/index.cjs +1 -0
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +2 -1
- package/dist/production/src/client/AcquiredConnection.cjs +2 -0
- package/dist/production/src/client/AcquiredConnection.cjs.map +1 -1
- package/dist/production/src/client/AcquiredConnection.js +3 -1
- package/dist/production/src/client/AcquiredConnection.js.map +1 -1
- package/dist/production/src/client/errors.cjs +6 -1
- package/dist/production/src/client/errors.cjs.map +1 -1
- package/dist/production/src/client/errors.js +6 -1
- package/dist/production/src/client/errors.js.map +1 -1
- package/dist/production/src/utils/pgClientFactory.cjs.map +1 -1
- package/dist/production/src/utils/pgClientFactory.js.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/client/AcquiredConnection.d.ts.map +1 -1
- package/dist/types/client/PgClient.d.ts +1 -1
- package/dist/types/client/PgClient.d.ts.map +1 -1
- package/dist/types/client/errors.d.ts +2 -0
- package/dist/types/client/errors.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/utils/pgClientFactory.d.ts +1 -2
- package/dist/types/utils/pgClientFactory.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/client/AcquiredConnection.ts +3 -0
- package/src/client/PgClient.ts +2 -1
- package/src/client/errors.ts +9 -3
- package/src/utils/pgClientFactory.ts +1 -3
- package/tests/cases/unit/acquiredConnection.test.ts +40 -0
|
@@ -167,3 +167,43 @@ for (
|
|
|
167
167
|
await expect(connection.query('SELECT 1')).rejects.toThrow(InvalidDataError)
|
|
168
168
|
})
|
|
169
169
|
}
|
|
170
|
+
|
|
171
|
+
it('puts the PostgreSQL detail and hint of a failed query into the error message', async () => {
|
|
172
|
+
const connection = new AcquiredConnection(
|
|
173
|
+
createPgClientMock(async () => {
|
|
174
|
+
throw Object.assign(new Error('cannot drop column otp_uri of table person because other objects depend on it'), {
|
|
175
|
+
code: '2BP01',
|
|
176
|
+
detail: 'view app.person_otp depends on column otp_uri of table person',
|
|
177
|
+
hint: 'Use DROP ... CASCADE to drop the dependent objects too.',
|
|
178
|
+
})
|
|
179
|
+
}),
|
|
180
|
+
new EventManager(),
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
const error = await connection.query('ALTER TABLE person DROP COLUMN otp_uri').catch(e => e)
|
|
184
|
+
if (!(error instanceof QueryError)) {
|
|
185
|
+
throw error
|
|
186
|
+
}
|
|
187
|
+
expect(error.message).toBe(
|
|
188
|
+
'Database query error: cannot drop column otp_uri of table person because other objects depend on it\n'
|
|
189
|
+
+ 'Detail: view app.person_otp depends on column otp_uri of table person\n'
|
|
190
|
+
+ 'Hint: Use DROP ... CASCADE to drop the dependent objects too.\n'
|
|
191
|
+
+ 'SQL: ALTER TABLE person DROP COLUMN otp_uri\n'
|
|
192
|
+
+ 'parameters: ',
|
|
193
|
+
)
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
it('leaves detail and hint out of the error message when PostgreSQL sends none', async () => {
|
|
197
|
+
const connection = new AcquiredConnection(
|
|
198
|
+
createPgClientMock(async () => {
|
|
199
|
+
throw Object.assign(new Error('relation "missing" does not exist'), { code: '42P01', detail: undefined, hint: undefined })
|
|
200
|
+
}),
|
|
201
|
+
new EventManager(),
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
const error = await connection.query('SELECT * FROM missing').catch(e => e)
|
|
205
|
+
if (!(error instanceof QueryError)) {
|
|
206
|
+
throw error
|
|
207
|
+
}
|
|
208
|
+
expect(error.message).toBe('Database query error: relation "missing" does not exist\nSQL: SELECT * FROM missing\nparameters: ')
|
|
209
|
+
})
|