QueryFailedError (Invalid parameter) occurs at typeorm insert into table for sap (HANA) database
See original GitHub issueIssue Description
Expected Behavior
No error shall occur, and a new record has been inserted into table "<HANA_SCHEMA>"."photo"
.
Actual Behavior
An error occurs at typeorm database operation. Though, the expected record has been inserted into the table. Server console output:
[Nest] 5090 - 08/02/2021, 7:15:24 PM ERROR [ExceptionsHandler] Invalid parameter for function 'exec[ute](sql[, params][, options][, callback])'
QueryFailedError: Invalid parameter for function 'exec[ute](sql[, params][, options][, callback])'
at QueryFailedError.TypeORMError [as constructor] (/home/niels/sap/issues/typeorm-hana-insert-into-table/src/error/TypeORMError.ts:7:9)
at new QueryFailedError (/home/niels/sap/issues/typeorm-hana-insert-into-table/src/error/QueryFailedError.ts:9:9)
at SapQueryRunner.<anonymous> (/home/niels/sap/issues/typeorm-hana-insert-into-table/src/driver/sap/SapQueryRunner.ts:221:34)
at step (/home/niels/sap/issues/typeorm-hana-insert-into-table/node_modules/tslib/tslib.js:143:27)
at Object.next (/home/niels/sap/issues/typeorm-hana-insert-into-table/node_modules/tslib/tslib.js:124:57)
at /home/niels/sap/issues/typeorm-hana-insert-into-table/node_modules/tslib/tslib.js:117:75
at new Promise (<anonymous>)
at Object.__awaiter (/home/niels/sap/issues/typeorm-hana-insert-into-table/node_modules/tslib/tslib.js:113:16)
at ArgParser.cbfunc (/home/niels/sap/issues/typeorm-hana-insert-into-table/src/driver/sap/SapQueryRunner.ts:219:82)
at ConnectionExecCallback (/home/niels/sap/issues/typeorm-hana-insert-into-table/node_modules/@sap/hana-client/lib/index.js:489:22)
Steps to Reproduce
Prepare:
- Clone repository https://github.com/niels-schmitt/typeorm-hana-insert-into-table.
npm install
- Get a running HANA instance, and credentials for user <HANA_USER> with authorization
CREATE ANY
on schema <HANA_SCHEMA>. cp template.env .env
- In file
.env
enter values for:HANA_HOST
,HANA_PORT
,HANA_USER
,HANA_PASSWORD
,HANA_SCHEMA
Reproduce Issue:
npm run start
curl -X POST -H 'Content-Type: application/json' -d '["Flower"]' localhost:3000/photos
or
curl -X POST -H 'Content-Type: application/json' -d '["Tree"]' localhost:3000/photosByQueryBuilder
My Environment
Dependency | Version |
---|---|
Operating System | Ubuntu 20.04.2 |
Node.js version | v14.17.4 |
Typescript version | @4.3.5 |
TypeORM version | @0.2.36 |
@nestjs/core | @8.0.5 |
@nestjs/typeorm | @8.0.1 |
@sap/hana-client | @2.9.23 |
hdb-pool | @0.1.6 |
Additional Context
The error occurs since TypeORM version 0.2.35, it does not occur for TypeORM version 0.2.34.
POST for /photos
executes
await this.photoRepository.manager.insert(Photo, photos);
POST for /photosByQueryBuilder
executes
await this.photoRepository
.createQueryBuilder()
.insert()
.into(Photo)
.values(photos)
.execute();
The issues occurs for both variants.
(Read all records by
curl localhost:3000/photos
)
The issue does not occur in case a postgres database is connected.
To verify, set postgres credentials and DB_TYPE=postgres
in file .env
.
Relevant Database Driver(s)
DB Type | Reproducible |
---|---|
aurora-data-api |
|
aurora-data-api-pg |
|
better-sqlite3 |
|
cockroachdb |
|
cordova |
|
expo |
|
mongodb |
|
mysql |
|
nativescript |
|
oracle |
|
postgres |
no |
react-native |
|
sap |
yes |
sqlite |
|
sqlite-abstract |
|
sqljs |
|
sqlserver |
Are you willing to resolve this issue by submitting a Pull Request?
- ✖️ Yes, I have the time, and I know how to start.
- ✖️ Yes, I have the time, but I don’t know how to start. I would need guidance.
- ✖️ No, I don’t have the time, but I can support (using donations) development.
- ✅ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
XSODATA Multi Table Insert - SAP Community
i tried taking the user_id as IN parameter and writing my logic to INSERT records into the two tables (ABC & XYZ)for which...
Read more >typeorm-1/CHANGELOG.md at master - GitHub
Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
Read more >TypeORM throws QueryFailedError Table already exists on ...
I am using a .env file to pass in some environment variables for connecting to my local database. Synchronize is set to true...
Read more >typeorm: CHANGELOG
TypeORM now properly works when installed within different node_modules contexts (often happen if TypeORM is a dependency of another library or TypeORM is ......
Read more >Source - GitHub
It's user responsibility to name tables short if their RDBMS limit table name length since it ... correctly handle multiple-row insert for SAP...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was able to insert after https://github.com/typeorm/typeorm/pull/8072 was applied - can you confirm?
Same issue here when running migrations. The migration itself (create table) works without a problem, but registering the migration fails:
This error does not occur on typeorm 0.2.34.