-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Closed
Closed
Copy link
Labels
Description
Issue description
BigInt as value in find one where options fails on query cache id JSON serialization
Expected Behavior
SelectQueryBuilder.loadRawResults
does not fail if a value in query parameter is a bigint.
Actual Behavior
Fail because JSON does not know how to serialize bigint by default.
A fix is possible by changing SelectQueryBuilder.loadRawResults
. Exactly the creation of the query id for caching purposes. The query id is supposed to be a string, so casting the bigint to string should not bring any harm here.
Current implementation
const queryId = sql + " -- PARAMETERS: " + JSON.stringify(parameters);
A fix:
const queryId = sql + " -- PARAMETERS: " + JSON.stringify(parameters, (_, value) => typeof value === "bigint" ? value.toString() : value);
Steps to reproduce
@Entity('my_entity')
class MyEntity {
@Column('bigint')
public id: bigint;
}
...
entityRepository.findOne({ id: 1n })
My Environment
Dependency | Version |
---|---|
Operating System | |
Node.js version | x.y.zzz |
Typescript version | x.y.zzz |
TypeORM version | x.y.zzz |
Additional Context
No response
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?
Yes, I have the time, and I know how to start.