Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correctly handle enum values with multiple apostrophes in MySQL #8013

Merged
merged 1 commit into from Aug 11, 2021

Conversation

ianngiaw
Copy link
Contributor

@ianngiaw ianngiaw commented Aug 3, 2021

Description of change

Current implementation uses "'" in .replace which only replaces first occurrence of '.

value.replace("'", "''") // "dog's and cat's food" -> "dog''s and cat's food"

Changing to /'/g will allow for all instances of apostrophes to be replaced.

value.replace(/'/g, "''") // "dog's and cat's food" -> "dog''s and cat''s food"

Closes: #8011

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • npm run lint passes with this change
  • npm run test passes with this change
  • This pull request links relevant issues as Fixes #0000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change
  • The new commits follow conventions explained in CONTRIBUTING.md

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
@ianngiaw ianngiaw changed the title fix: correctly handle enums values with multiple apostrophes in MySQL fix: correctly handle enum values with multiple apostrophes in MySQL Aug 3, 2021
@imnotjames imnotjames merged commit 37c40a6 into typeorm:master Aug 11, 2021
@ianngiaw ianngiaw deleted the fix-enum-apostrophe-escaping branch August 12, 2021 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enum values with multiple apostrophes not properly escaped in MySQL
2 participants