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

QueryBuilder broken on web - Invalid regular expression: invalid group specifier name #7026

Closed
2 of 21 tasks
MorelSerge opened this issue Nov 6, 2020 · 31 comments · Fixed by #7270, mattwelke/typeorm-postgres-example#165 or newerton/gobarber-2-backend#17

Comments

@MorelSerge
Copy link

MorelSerge commented Nov 6, 2020

Issue Description

The QueryBuilder is broken in the new 0.2.29 release due to this change: #4760
Regex lookbehinds are not supported in on a lot of web environments, a fallback should be implemented.
This affects any driver that uses JavascriptCore (Safari, React Native, ...)

Expected Behavior

I'd expect QueryBuilder to work

Actual Behavior

QueryBuilder crashes with Invalid regular expression: invalid group specifier name

Steps to Reproduce

I would add an reproducible example, however, I feel the issue is clear enough without?

My Environment

Dependency Version
Operating System React Native, Android
Typescript version v4.0.5
TypeORM version v0.2.29

Additional Context

Relevant:

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?

  • Yes, I have the time, and I know how to start.
  • Yes, I have the time, but I don't know how to start. I would need guidance.
  • No, I don't have the time, although I believe I could do it if I had the time...
  • No, I don't have the time and I wouldn't even know how to start.
@imnotjames
Copy link
Contributor

imnotjames commented Nov 8, 2020

What version of Javascript does react native provide? That's bizarre that it doesn't provide these features.

@imnotjames
Copy link
Contributor

Looking at the react-native issues.. looks like the problem is brought up time and again - but never fixed.

We can work around it, but that sure does make things a bit messier..

@MorelSerge
Copy link
Author

React Native runs on JavascriptCore, which still does not support lookbehinds

@hhunaid
Copy link

hhunaid commented Nov 11, 2020

Is there any older version that works for react native or this has been always the case?

@MorelSerge
Copy link
Author

@hhunaid See the issue description, this was introduced only in 0.2.29

@FrankyFrankFrank
Copy link

@Vluf is correct, we rolled our project back to 0.2.25 and recovered from the bug.

@Cendeal
Copy link

Cendeal commented Nov 19, 2020

the root cause is node.js version. I meet the same cause. it is because i forget to change the node version back. this case will occur when I use oneToMany and node version is 8.3.0. i change node.js back to 10.19.0 is ok.

@MorelSerge
Copy link
Author

@Cendeal Nodejs is a different engine than the one this issue is for, but upgrading Node will also add support for lookbehinds.

@sandro-salles
Copy link

In order to overcome (even if temporarily) the lookbehinds issue (and the limitations of JavascriptCore), i'm using https://github.com/Kudo/react-native-v8

I can confirm it's working on my installation:

react-native@0.63.3
react-native-v8@^0.63.3-patch.0
typeorm@0.2.29
v8-android@~8.84.0

Hope it can help someone else... :)

@NickDelBen
Copy link

@sandro-salles I am having this exact issue and tried to switch to react-native-v8 as suggested, but when the app launches on the emulator it stope responding immediately. Perhaps you could share in more detail how you resolved this

@douglasndm
Copy link

Same problem here on 0.2.29

@jacobg
Copy link
Contributor

jacobg commented Nov 30, 2020

Have same problem when using Cordova on iOS, i.e., uses Safari's web kit WkWebView, same as React Native.

@bolivir
Copy link

bolivir commented Dec 1, 2020

Using it on Ionic Capacitor with version 0.2.29 causes this issue for me, reverting back to 0.2.28 solves it. Seems to be something with relationships

@johnvolkov
Copy link

Have same problem on ionic iOS with version 0.2.29.
Command find() without parameters work fine. But findOne or Delete broken with error: "SyntaxError: Invalid regular expression: invalid group specifier name RegExp@[native code]"

@oleksandr-dziuban
Copy link

Have same problem on ionic iOS with version 0.2.29.
Command find() without parameters work fine. But findOne or Delete broken with error: "SyntaxError: Invalid regular expression: invalid group specifier name RegExp@[native code]"

Same issue.... Have it on iOS and Android

@timroes
Copy link

timroes commented Dec 11, 2020

This issue was released now since a month and effects most Android/iOS and all Safari usages. It feels this should be critical enough to revert the causing PR and release a 0.2.30 timely?

@sandro-salles
Copy link

Any update on a fixed release guys? thanks so much....

@anhkieet
Copy link

Same issue... I don't see any action on this issue recently?

@chriswep
Copy link
Contributor

@Vluf i suggest to update the title and labels to reflect that this affects/breaks all web-based platforms and drivers. @imnotjames @pleerock did this issue already came to your attention? i agree with @timroes and others that this issue merits a revert of #4760

@nebkat
Copy link
Contributor

nebkat commented Dec 19, 2020

I think #4760 made more changes than just adding the lookahead/behind, and there have also been some further improvements made to the function since then. Someone should look at reimplementing the current code without using lookbehinds and submit a pull requests that allows either syntax to be used. Hopefully that can then be merged quicker than a revert since it won't affect non-ionic/browser users.

@MorelSerge MorelSerge changed the title QueryBuilder broken in React Native - Invalid regular expression: invalid group specifier name QueryBuilder broken on web - Invalid regular expression: invalid group specifier name Dec 19, 2020
@MorelSerge
Copy link
Author

@chriswep Updated title & description to reflect this, can't update the labels though.

@sdserage
Copy link

Another duplicate:

#7157

@sdserage
Copy link

Trying to drop to a lower version so I can use this library but I get this error for 0.2.28 and 0.2.25:

Unable to resolve "./find-options/operator/ILike" from "node_modules/typeorm/browser/index.js"

Anybody know if there is a work around for this?

@allandiego
Copy link
Contributor

allandiego commented Dec 28, 2020

@sdserage Im using version 0.2.27 on react native and its working

@anhkieet
Copy link

@sdserage Im using version 0.2.27 on react native and its working

Which react-native version are you using?

@douglasndm
Copy link

I was able to fix this downgrading to 0.25.5 and removing all URL imports and calls from BrowserUtils inside typeorm module

@sdserage
Copy link

sdserage commented Jan 5, 2021

@sdserage Im using version 0.2.27 on react native and its working

Which react-native version are you using?

I'm using 0.63.4

@MorelSerge
Copy link
Author

FYI the changes have been reverted and a PR has been made: #7269
0.2.31 should fix & close this issue
Thanks pleerock

pleerock pushed a commit that referenced this issue Jan 18, 2021
Lookbehind isn't supported in Safari/JavaScriptCore environments.

Closes: #7026
@LuigiMaestrelli
Copy link

Any ideas on when this will be released?
Every single release from 0.2.25 to 0.2.30 has some kind of bug on react-native...

@f-ricci
Copy link

f-ricci commented Feb 4, 2021

Hi @pleerock , could you give us an estimate when the 0.2.31 version will be released?

@f-ricci
Copy link

f-ricci commented Feb 5, 2021

For whomever gets here looking for answers, until the release is published, you can build the package locally and use your local build as dependency in your project.

These are the steps I followed:

  1. clone the repo on your local machine
  2. run npm install --save-dev
  3. run npm run compile
  4. run npm run package

In your project

  1. in your project folder, change the typeorm dependency in package.json to use the local build
    using yarn is something like this "typeorm": "file:PATH_TO_CLONED_REPO/build/package",
  2. delete node_modules
  3. run yarn install --dev
  4. restart the simulator / emulator

This worked for me. Comment if you find any trouble.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment