You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All apostrophes in the enum should be escaped in the generated add column migration.
Actual Behavior
Only the first apostrophe is properly escaped. Subsequent apostrophes are left unescaped, resulting in a QueryFailedError when running the migration.
QueryFailedError: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's Clothing', 'Footwear') NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB' at line 1
at new QueryFailedError (/typeorm-test-proj/src/error/QueryFailedError.ts:9:9)
at Query.onResult (/typeorm-test-proj/src/driver/mysql/MysqlQueryRunner.ts:193:37)
at Query.execute (/typeorm-test-proj/node_modules/mysql2/lib/commands/command.js:30:14)
at PoolConnection.handlePacket (/typeorm-test-proj/node_modules/mysql2/lib/connection.js:425:32)
at PacketParser.onPacket (/typeorm-test-proj/node_modules/mysql2/lib/connection.js:75:12)
at PacketParser.executeStart (/typeorm-test-proj/node_modules/mysql2/lib/packet_parser.js:75:16)
at Socket.<anonymous> (/typeorm-test-proj/node_modules/mysql2/lib/connection.js:82:25)
Steps to Reproduce
Create an enum with multiple apostrophes in a single value
enumCategory{MensAndWomensClothing="Men's and Women's Clothing",Footwear='Footwear',}
Current implementation uses `"'"` in replace which only replaces first occurrence of `'`.
Changing to `/'/g` will allow for all instances of apostrophes to be replaced.
Closes: typeorm#8011
Current implementation uses `"'"` in replace which only replaces first occurrence of `'`.
Changing to `/'/g` will allow for all instances of apostrophes to be replaced.
Closes: #8011
Issue Description
Expected Behavior
All apostrophes in the enum should be escaped in the generated add column migration.
Actual Behavior
Only the first apostrophe is properly escaped. Subsequent apostrophes are left unescaped, resulting in a
QueryFailedError
when running the migration.Steps to Reproduce
Output:
My Environment
Additional Context
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
Are you willing to resolve this issue by submitting a Pull Request?
The text was updated successfully, but these errors were encountered: