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

Issue Description

The QueryBuilder is broken in the new 0.2.29 release due to this change: https://github.com/typeorm/typeorm/pull/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.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 20
  • Comments: 31 (6 by maintainers)

Commits related to this issue

Most upvoted comments

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…

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?

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

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]”

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

@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

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.

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

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.

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… 😃

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…