Description
Issue description
SAP HANA cannot bind array parameter for prepared statement
Expected Behavior
should be changed to:
if (parameters?.length > 0 && !parameters.some(Array.isArray)) {
statement = await promisify(databaseConnection.prepare).call(
databaseConnection,
query,
)
}
This will ensure:
- queries with parameters are prepared
- queries with no parameters are not prepared, as per SAP recommendation If a SQL statement does not take parameters, Connection.exec[ute] is recommended over Statement.exec[ute] as it requires fewer round trips to the server.
- queries with array(s) as parameters are not prepared
One could replace each individual item in the array as parameter (IN (?, ?)
instead of IN (?)
), but this could cause problems for large arrays.
The comment in the PR perf: improve SapQueryRunner performance #10198 was not added, but I assume the condition should be negated as per my recommendation.
Actual Behavior
Only queries with an array as a parameter will be executed as a prepared statement. This will result in the error Cannot bind parameter
, because HANA does not support binding a parameter to an array.
Steps to reproduce
Any query where the parameter is an array, e.g. .where('u.userId IN (:arrayValues)', { arrayValues: [1, 2] });
My Environment
Dependency | Version |
---|---|
Operating System | |
Node.js version | 22.13.0 |
Typescript version | 5.8.2 |
TypeORM version | 0.3.20 |
Additional Context
No response
Relevant Database Driver(s)
- aurora-mysql
- aurora-postgres
- better-sqlite3
- cockroachdb
- cordova
- expo
- mongodb
- mysql
- nativescript
- oracle
- postgres
- react-native
- sap
- spanner
- 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.