Description
Issue description
When using TypeORM with Alibaba Cloud AnalyticDB for MySQL (ADS), the getVersion()
function in MysqlQueryRunner
fails due to ADS returning the version information under the key version()
instead of version
. This causes a TypeError when calling .replace()
on undefined if result[0].version
is not available. Related driver: mysql / mysql2
Expected Behavior
TypeORM should correctly parse the version string returned from ADS, even when the field name is version()
, and not throw an error.
Actual Behavior
TypeORM crashes with:
TypeError: Cannot read properties of undefined (reading 'replace')
at MysqlQueryRunner.getVersion (...)
The query result from ADS is:
[ { 'version()': '5.6.16-log' } ]
In the current implementation, result[0].version
is undefined, and result[0]['version()']
should be used instead.
Steps to reproduce
- Use TypeORM with
type: 'mysql'
- Connect to Alibaba Cloud AnalyticDB for MySQL (ADS)
- Let TypeORM call
getVersion()
internally - Observe TypeError when parsing the version string
My Environment
Dependency | Version |
---|---|
Operating System | macos |
Node.js version | 22.0.0 |
Typescript version | 5.1.3 |
TypeORM version | 0.3.25 |
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.