-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Labels
Description
Issue Description
Expected Behavior
Two new records have been created in table "<HANA_SCHEMA>"."photo".
Actual Behavior
An error occurs at typeorm database operation. No records have been created on database. Server console output:
[Nest] 1032 - 07/13/2021, 8:27:38 AM ERROR [ExceptionsHandler] sql syntax error: incorrect syntax near ",": line 1 col 48 (at pos 48)
Error: sql syntax error: incorrect syntax near ",": line 1 col 48 (at pos 48)
at SapQueryRunner.<anonymous> (/home/niels/sap/issues/typeorm-hana-insert-multiple-rows/src/driver/sap/SapQueryRunner.ts:193:53)
at step (/home/niels/sap/issues/typeorm-hana-insert-multiple-rows/node_modules/tslib/tslib.js:143:27)
at Object.next (/home/niels/sap/issues/typeorm-hana-insert-multiple-rows/node_modules/tslib/tslib.js:124:57)
at fulfilled (/home/niels/sap/issues/typeorm-hana-insert-multiple-rows/node_modules/tslib/tslib.js:114:62)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
Steps to Reproduce
Prepare:
- Clone repository https://github.com/niels-schmitt/typeorm-hana-insert-multiple-rows.
npm install- Get a running HANA instance, and credentials for user <HANA_USER> with authorization
CREATE ANYon schema <HANA_SCHEMA>. cp template.env .env- In file
.enventer values for:HANA_HOST,HANA_PORT,HANA_USER,HANA_PASSWORD,HANA_SCHEMA
Reproduce Issue:
npm run startcurl -w'\n' -X POST -H 'Content-Type: application/json' -d '["Flower","Tree"]' localhost:3000/photosor
curl -w'\n' -X POST -H 'Content-Type: application/json' -d '["Flower","Tree"]' localhost:3000/photosByQueryBuilderMy Environment
| Dependency | Version |
|---|---|
| Operating System | Ubuntu 20.04.2 |
| Node.js version | v14.17.2 |
| Typescript version | @4.3.5 |
| TypeORM version | @0.2.34 |
| @nestjs/core | @8.0.2 |
| @nestjs/typeorm | @8.0.1 |
| @sap/hana-client | @2.9.23 |
| hdb-pool | @0.1.6 |
Additional Context
Root cause seems to be that an incorrect SQL is created:
INSERT INTO "photo"("id", "name") VALUES (?, ?), (?, ?)Correct SQL would be:
INSERT INTO "photo"("id", "name") VALUES ((?, ?), (?, ?))The executed SQL is logged to the console in case of POST for /photosByQueryBuilder.
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.
The issue does not occur in case only one record is inserted:
curl -w'\n' -X POST -H 'Content-Type: application/json' -d '["Flower"]' localhost:3000/photosor
curl -w'\n' -X POST -H 'Content-Type: application/json' -d '["Tree"]' localhost:3000/photosByQueryBuilderFor verification, read all records by
curl -w'\n' localhost:3000/photosThe issue does not occur in case a postgres database is connected.
Relevant Database Driver(s)
-
aurora-data-api -
aurora-data-api-pg -
better-sqlite3 -
cockroachdb -
cordova -
expo -
mongodb -
mysql -
nativescript -
oracle -
postgres -
react-native -
sap -
sqlite -
sqlite-abstract -
sqljs -
sqlserver
Thanks for your help & kind regards
Niels Schmitt