Skip to content

Bug: getVersion() fails with AnalyticDB MySQL due to non-standard field name version() #11553

Open
@rhydian0x

Description

@rhydian0x

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

  1. Use TypeORM with type: 'mysql'
  2. Connect to Alibaba Cloud AnalyticDB for MySQL (ADS)
  3. Let TypeORM call getVersion() internally
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions