You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Program throws an error when attempting to execute transactions
Expected Behavior
Database is queried without any issue
Actual Behavior
TypeError is thrown:
(node:29724) UnhandledPromiseRejectionWarning: TypeError: Class constructor PuzzleEntity cannot be invoked without 'new'
at SelectQueryBuilder.createFromAlias (C:\Users\David Stewart\Downloads\o_my_word-main\o_my_word-main\web_app\server\node_modules\typeorm\query-builder\QueryBuilder.js:424:37)
at SelectQueryBuilder.from (C:\Users\David Stewart\Downloads\o_my_word-main\o_my_word-main\web_app\server\node_modules\typeorm\query-builder\SelectQueryBuilder.js:164:32)
at C:\Users\David Stewart\Downloads\o_my_word-main\o_my_word-main\web_app\server\dist\app.js:73:10
at Generator.next (<anonymous>)
at C:\Users\David Stewart\Downloads\o_my_word-main\o_my_word-main\web_app\server\node_modules\tslib\tslib.js:117:75
at new Promise (<anonymous>)
at Object.__awaiter (C:\Users\David Stewart\Downloads\o_my_word-main\o_my_word-main\web_app\server\node_modules\tslib\tslib.js:113:16)
at getCurrentPuzzle (C:\Users\David Stewart\Downloads\o_my_word-main\o_my_word-main\web_app\server\dist\app.js:68:40)
at Object.<anonymous> (C:\Users\David Stewart\Downloads\o_my_word-main\o_my_word-main\web_app\server\dist\app.js:81:30)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:29724) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:29724) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Steps to reproduce
Code to reproduce:
import{BaseEntity,Column,ConnectionOptions,DataSource,Entity,PrimaryGeneratedColumn}from'typeorm';interfaceIPuzzle{puzzle: string[][];puzzle_num: number;active_from: Date;active_to: Date;}
@Entity()classPuzzleEntityextendsBaseEntityimplementsIPuzzle{
@PrimaryGeneratedColumn()id: number;
@Column('jsonb')puzzle: string[][];
@Column({unique: true})puzzle_num: number;
@Column({type: 'timestamptz',nullable: false})active_from: Date;
@Column({type: 'timestamptz',nullable: false})active_to: Date;}exportconstdbConnection: ConnectionOptions={type: 'postgres',host: 'localhost',port: 5432,username: 'root',password: 'admin',database: 'test',synchronize: true,logging: false,entities: [PuzzleEntity],};console.log('Creating data source');constappDataSource=newDataSource(dbConnection);console.log('Initializing data source');appDataSource.initialize();constgetCurrentPuzzle=async(): Promise<PuzzleEntity>=>{constnow=newDate();constres=awaitappDataSource.createQueryBuilder().select("Puzzle").from(PuzzleEntity,"Puzzle").where(":now > Puzzle.active_from AND :now < Puzzle.active_to ",{ now }).orderBy('active_from','DESC').getOne();returnres;}console.log('Attempting to query');getCurrentPuzzle().then(p=>console.log(p));
Creating data source
Initializing data source
Attempting to query
(node:9148) UnhandledPromiseRejectionWarning: TypeError: Class constructor PuzzleEntity cannot be invoked without 'new'
at SelectQueryBuilder.createFromAlias (C:\Users\David Stewart\Downloads\o_my_word-main\o_my_word-main\web_app\server\node_modules\typeorm\query-builder\QueryBuilder.js:424:37)
My Environment
Dependency
Version
Operating System
Windows 11
Node.js version
14.6.0
Typescript version
4.7.4
TypeORM version
0.3.11
Additional Context
I am in the middle of porting code that was written using TypeORM v 0.2.34. I've done my best to extract the smallest amount of code to reproduce the error. I cannot see how this code is materially different from how it was (working) with v 0.2.34 - i've checked similar issues such as this one but the solution of changing the target to es6 did not work for me.
Relevant Database Driver(s)
aurora-mysql
aurora-postgres
better-sqlite3
cockroachdb
cordova
expo
mongodb
mysql
nativescript
oracle
postgres
react-native
sap
spanner
sqlite
sqlite-abstract
sqljs
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
The text was updated successfully, but these errors were encountered:
Issue description
Program throws an error when attempting to execute transactions
Expected Behavior
Database is queried without any issue
Actual Behavior
TypeError
is thrown:Steps to reproduce
Code to reproduce:
tsconfig.json:
Output:
My Environment
Additional Context
I am in the middle of porting code that was written using TypeORM v 0.2.34. I've done my best to extract the smallest amount of code to reproduce the error. I cannot see how this code is materially different from how it was (working) with v 0.2.34 - i've checked similar issues such as this one but the solution of changing the target to es6 did not work for me.
Relevant Database Driver(s)
Are you willing to resolve this issue by submitting a Pull Request?
No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
The text was updated successfully, but these errors were encountered: