-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Description
Issue description
When TypeORM generates hash-based aliases, the resulting alias can start with a digit (0-9). This creates invalid SQL identifiers that cause syntax errors when used in raw queries.
Expected Behavior
Generated aliases should always start with a letter to create valid SQL identifiers that can be safely used in all SQL contexts.
Actual Behavior
raw queries fail with SQL syntax errors when auto-generated aliases start with digits:
QueryFailedError: trailing junk after numeric literal at or near "[alias_starting_with_digit]"
Steps to reproduce
- Use nested relations that generate long internal aliases
- Apply a
Raw()
filter that references the generated alias - Error occurs when the generated hash starts with a digit
My Environment
Dependency | Version |
---|---|
Operating System | Windows |
Node.js version | v20.10.0 |
Typescript version | 5.8.3 |
TypeORM version | 0.3.26 |
Additional Context
This issue occurs with nested relations where TypeORM internally generates aliases for deep object property paths. The problem is deterministic - certain relation paths will consistently generate problematic aliases while others work fine.
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.