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

NativeScript Query Runner has a scope issue in its query() method #8180

Closed
pekevski opened this issue Sep 14, 2021 · 1 comment · Fixed by #8182
Closed

NativeScript Query Runner has a scope issue in its query() method #8180

pekevski opened this issue Sep 14, 2021 · 1 comment · Fixed by #8182

Comments

@pekevski
Copy link
Contributor

Issue Description

NativescriptQueryRunner handler function inside promise has an issue with scoping of "this". I think it may occur when targeting a higher es module than commonjs?

Expected Behavior

TypeORM will run with a nativescript-sqlite database without any issues on startup.
(Assuming all of TypeORM's node poly fills have been added as NativeScript 8 now runs on webpack v5)

Actual Behavior

When using TypeORM v0.2.37 in a NativeScript 8 project with a TypeScript configuration

module: esnext
target: es2017

The app does not start and throws the following error. Suggesting that this is undefined. in the NativescriptQueryRunner.ts file as below:

CONSOLE ERROR: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'driver' of undefined
TypeError: Cannot read property 'driver' of undefined
at handler (file: src/webpack:/@nativescript/template-hello-world-ng/node_modules/typeorm/driver/nativescript/NativescriptQueryRunner.js:41:0)
... ivy logs...

Steps to Reproduce

  1. Install nativescript npm i -g nativescript (should be version 8.1.1 of writing this)
  2. Fork or clone https://github.com/pekevski/typeorm-ns8-ng-example.git
  3. In package.json set typeorm to 0.2.37
  4. Run the app with ns run ios or ns run android

My Environment

Dependency Version
Operating System MacOS v11.5.2 (BigSur)
Node.js version v14.16.0
Typescript version 4.2.4
TypeORM version 0.2.37

Additional Context

None

Relevant Database Driver(s)

DB Type Reproducible
aurora-data-api no
aurora-data-api-pg no
better-sqlite3 no
cockroachdb no
cordova no
expo no
mongodb no
mysql no
nativescript yes
oracle no
postgres no
react-native no
sap no
sqlite no
sqlite-abstract no
sqljs no
sqlserver no

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, but I can support (using donations) development.
  • ✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
pekevski added a commit to pekevski/typeorm that referenced this issue Sep 14, 2021
…iptQueryRunner. this.driver is not defined.

Making the promise async now correctly scopes the handler.
Additional corrections were made to the syntax, eg conditionals.
pekevski added a commit to pekevski/typeorm that referenced this issue Sep 14, 2021
…iptQueryRunner. this.driver is not defined.

Making the promise async now correctly scopes the handler.
Additional corrections were made to the syntax, eg conditionals.
pekevski added a commit to pekevski/typeorm that referenced this issue Sep 14, 2021
…iptQueryRunner. this.driver is not defined.

Making the promise async now correctly scopes the handler.
Additional corrections were made to the syntax, eg conditionals.
pekevski added a commit to pekevski/typeorm that referenced this issue Sep 14, 2021
…iptQueryRunner. this.driver is not defined.

Making the promise async now correctly scopes the handler.
Additional corrections were made to the syntax, eg conditionals.
pekevski added a commit to pekevski/typeorm that referenced this issue Sep 14, 2021
…iptQueryRunner. this.driver is not defined.

Making the promise async now correctly scopes the handler.
Additional corrections were made to the syntax, eg conditionals.
pekevski added a commit to pekevski/typeorm that referenced this issue Sep 14, 2021
…r.ts

Making the promise async now correctly scopes the handler. this.driver is now defined.
Additional corrections were made to the syntax, eg conditionals.

Closes typeorm#8180
@pekevski
Copy link
Contributor Author

Sorry (cant amend commit messages very well) 😢

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

Successfully merging a pull request may close this issue.

1 participant