cds-dbs
cds-dbs copied to clipboard
`Postgres` pool `validate()` function always returns `undefined`
Description of erroneous behaviour
It seems when initially creating the PostgresService class, code was copy-pasted from SQLiteService, as a result, pool validate() function is defined as dbc => dbc.open. The issue is that open property exists on SQLite client but the Postgres client does not have this property and validate() always returns undefined. This kind of validate() function breaks Postgres borrow and eviction pool tests.
@danjoa can you share your thoughts about the issue?
Issue #759 might be related.
Detailed steps to reproduce
- Set pool
maxconnections to > 1 and enabletestOnBorrowoption. - Debug to verify if connections are correctly reused.
Additional thoughts
- Maybe it's time to consider adopting TypeScript to avoid issues like this or this. TS can also be adopted incrementally without the need to migrate the whole codebase in one go.
- Generic Pool library seems to be unmaintained for a long time now with the latest version released 3 years ago. Maybe at least for Postgres it would make sense to use pg-pool instead?
Details about your project
| Package | Version |
|---|---|
| @cap-js/asyncapi | 1.0.3 |
| @cap-js/cds-types | 0.10.0 |
| @cap-js/change-tracking | 1.0.8 |
| @cap-js/db-service | 1.20.0 |
| @cap-js/openapi | 1.2.1 |
| @cap-js/postgres | 1.14.0 |
| @sap/cds | 8.9.2 |
| @sap/cds-compiler | 5.9.2 |
| @sap/cds-dk | 8.9.2 |
| @sap/cds-fiori | 1.4.1 |
| @sap/cds-foss | 5.0.1 |
| @sap/cds-mtxs | 2.7.2 |
| @sap/eslint-plugin-cds | 3.2.0 |
| Node.js | v22.13.1 |