-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: pass through of arbitrary client options (#1024)
Pass through of arbitrary client options should be possible. The database services do not interpret this but simply pass through information to the respective db clients. ```json { "db": { "kind": "hana", "credentials": { ... }, "client": { "packetSize": 1048576}, } } ``` This sample refers to the [`packetSize` parameter of `hdb`](https://github.com/SAP/node-hdb?tab=readme-ov-file#controlling-the-maximum-packet-size). For Hana MT and SQLite the "ugly reuse" of credentials is not possible. In Hana MT, the credentials for the db connection are not in environment but provided by service manager. In SQLite, the credentials and options are different parameters for the client. SQLite options: https://github.com/WiseLibs/better-sqlite3/blob/master/docs/api.md#new-databasepath-options Postgres options: https://node-postgres.com/apis/client#new-client hdb options: https://github.com/SAP/node-hdb?tab=readme-ov-file#cesu-8-encoding-support hana-client options: https://help.sap.com/docs/PRODUCT_ID/f1b440ded6144a54ada97ff95dac7adf/4fe9978ebac44f35b9369ef5a4a26f4c.html?state=PRODUCTION&version=latest&locale=en-US closes #994 closes #920
- Loading branch information
1 parent
bae7f68
commit b090ccd
Showing
9 changed files
with
57 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "@test/cds-db-layer", | ||
"version": "1.0.0", | ||
"description": "Base for db layer validations", | ||
"cds": { | ||
"requires": { | ||
"db": { | ||
"impl": "@cap-js/sqlite" | ||
} | ||
}, | ||
"features": { | ||
"ieee754compatible": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const assert = require('assert') | ||
const cds = require('../cds.js') | ||
cds.test.in(__dirname + '/resources') | ||
|
||
const clientOption = cds.env.requires.db.client | ||
let called = 0 | ||
Object.defineProperty(cds.env.requires.db, 'client', { | ||
get: () => { | ||
called++ | ||
return clientOption | ||
} | ||
}) | ||
/** | ||
* Tests explicitely, that all DBs access the specific client options | ||
*/ | ||
describe('affected rows', () => { | ||
cds.test() | ||
|
||
test('client option is called during bootstrapping', async () => { | ||
assert.strictEqual(called,1) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters