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: avoid regex lookbehind for compatibility #7270

Merged
merged 1 commit into from
Jan 18, 2021
Merged

fix: avoid regex lookbehind for compatibility #7270

merged 1 commit into from
Jan 18, 2021

Conversation

mohd-akram
Copy link
Contributor

Description of change

Closes #7026

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
  • The new commits follow conventions explained in CONTRIBUTING.md

@@ -624,12 +624,12 @@ export abstract class QueryBuilder<Entity> {

if (replacementKeys.length) {
statement = statement.replace(new RegExp(
`(?<=[ =\(]|^.{0})` +
`([ =\(]|^.{0})` +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this change but while we're here what is the effect of the .{0}?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, seems to have originated here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

considering the code-change: since this is not reverting the code to the last known working state but "just" removing the lookbehind expression from the regex - can you comment on how this code still accomplishes what it should do?
And maybe we should add a code-comment here about the regex-compatibility issue so that the next guy is not introducing the same thing again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous code did the same thing with the replacement. Lookahead/behind are just a simplification. I added a comment.

@pleerock
Copy link
Member

@Vluf @chriswep can you guys check if this fix works on react-native? If so, I'll merge this PR.

@MorelSerge
Copy link

@pleerock This PR fixes my issue on react-native, thanks!

@chriswep
Copy link
Contributor

@Vluf @chriswep can you guys check if this fix works on react-native? If so, I'll merge this PR.

@pleerock to clarify, the issue is not with react-native per se, but with a lot of web-environments not supporting regex-lookbehind, including Safari. can't do a test right now, however since the lookbehind is removed it should not throw the error anymore. i can't speak into if the corresponding method still works correctly (see code commit above) - is this method tested properly?

@pleerock
Copy link
Member

@pleerock to clarify, the issue is not with react-native per se, but with a lot of web-environments not supporting regex-lookbehind, including Safari.

yes, I got it. My point was to ask people (who use react native or web-env) to test these changes.

Lookbehind isn't supported in Safari/JavaScriptCore environments.

Closes: #7026
@pleerock pleerock merged commit 063d27f into typeorm:master Jan 18, 2021
@pleerock
Copy link
Member

Thank you @mohd-akram

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.

QueryBuilder broken on web - Invalid regular expression: invalid group specifier name
5 participants