Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: TypeError for cds bind in MTX scenario #482

Merged
merged 1 commit into from
Feb 27, 2024
Merged

Conversation

swaldmann
Copy link
Contributor

@swaldmann swaldmann commented Feb 27, 2024

With @cap-js/hana I get the following error (in dev/cds-mtxs/test/bookshop):

cds run --profile hana --resolve-bindings
TypeError: Cannot read properties of undefined (reading 'driver')
    at get factory [as factory] (/Users/D061687/Desktop/dev/cds-dbs/hana/lib/HANAService.js:32:76)
    at <instance_members_initializer> (/Users/D061687/Desktop/dev/cds-dbs/db-service/lib/common/DatabaseService.js:18:54)
    at new DatabaseService (/Users/D061687/Desktop/dev/cds-dbs/db-service/lib/common/DatabaseService.js:8:1)
    at new SQLService (/Users/D061687/Desktop/dev/cds-dbs/db-service/lib/SQLService.js:321:5)
    at new HANAService (/Users/D061687/Desktop/dev/cds-dbs/hana/lib/HANAService.js:16:1)
    at _use (/Users/D061687/Desktop/dev/cds/lib/srv/factory.js:23:42)
    at _use (/Users/D061687/Desktop/dev/cds/lib/srv/factory.js:26:42)
    at _use (/Users/D061687/Desktop/dev/cds/lib/srv/factory.js:27:63)
    at async connect.to (/Users/D061687/Desktop/dev/cds/lib/srv/cds-connect.js:48:11)
    at async cds_server (/Users/D061687/Desktop/dev/cds/server.js:34:33)
/Users/D061687/Desktop/dev/cds-dbs/hana/lib/HANAService.js:32
    const driver = drivers[this.options.driver || this.options.credentials.driver]?.driver || drivers.default.driver

This PR fixes the TypeError.

Explanation:
The await cds.connect.to ('db') is called here before cds bind resolves the credentials property. In an MTX scenario this doesn't matter though, as the credentials are fetched from Service Manager at runtime. Subsequent subscriptions etc. also work fine with this patch.

@swaldmann swaldmann changed the title Fix TypeError for cds bind in MTX scenario fix TypeError for cds bind in MTX scenario Feb 27, 2024
@swaldmann swaldmann changed the title fix TypeError for cds bind in MTX scenario fix: TypeError for cds bind in MTX scenario Feb 27, 2024
@swaldmann swaldmann merged commit 38722fe into main Feb 27, 2024
7 checks passed
@swaldmann swaldmann deleted the hana-cds-bind branch February 27, 2024 19:53
@cap-bots cap-bots mentioned this pull request Feb 27, 2024
johannes-vogel pushed a commit that referenced this pull request Feb 28, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>db-service: 1.6.4</summary>

##
[1.6.4](db-service-v1.6.3...db-service-v1.6.4)
(2024-02-28)


### Fixed

* **`cqn2sql`:** smart quoting also for update statements
([#475](#475))
([1688f77](1688f77))
* `INSERT` with first `undefined` value
([#484](#484))
([c21e3c4](c21e3c4))
* Allow SELECT.join queries again with full infer call
([#469](#469))
([5329ec0](5329ec0))
* optimize foreign key access in a join relevant path
([#481](#481))
([5e30de4](5e30de4)),
closes [#479](#479)
</details>

<details><summary>hana: 0.0.6</summary>

##
[0.0.6](hana-v0.0.5...hana-v0.0.6)
(2024-02-28)


### Added

* cds.Vector support for the HANAService
([#442](#442))
([1057a13](1057a13))


### Fixed

* `TypeError` for `cds bind` in MTX scenario
([#482](#482))
([38722fe](38722fe))
* Allow SELECT.join queries again with full infer call
([#469](#469))
([5329ec0](5329ec0))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants