chore: Update typeorm to v3
When I want to use the find operator with the column that has the transform property. It can not work well. It has been fixed by https://github.com/typeorm/typeorm/pull/9777. So I want to update typeorm to v3. But it brings in another issue https://github.com/typeorm/typeorm/issues/9316.
Assume there exists a table table_a.
| field_a | field_b |
|---|---|
| 'a1' | 'b1' |
| 'a2' | null |
- If we work with v2.
const repo = connection.getRepository(TableA)
// console []
console.log(await repo.find({ field_b: undefined }))
// console [ TableA { field_b: null, field_a: 'a2' } ]
console.log(await repo.find({ field_b: null }))
// console []
console.log(await repo.createQueryBuilder('table_a').where({ field_b: undefined }).getMany())
// console [ TableA { field_b: null, field_a: 'a2' } ]
console.log(await repo.createQueryBuilder('table_a').where({ field_b: null }).getMany())
- If we work with v3.
const repo = connection.getRepository(TableA)
// console [TableA { field_b: 'b1', field_a: 'a1' }, TableA { field_b: null, field_a: 'a2' }]
console.log(await repo.findBy({ field_b: undefined }))
// console [TableA { field_b: 'b1', field_a: 'a1' }, TableA { field_b: null, field_a: 'a2' }]
console.log(await repo.findBy({ field_b: null }))
// console [TableA { field_b: null, field_a: 'a2' }], this is the recommended usage for v3, use IsNull to filter null field.
console.log(await repo.findBy({ field_b: IsNull() }))
// console []
console.log(await repo.createQueryBuilder('table_a').where({ field_b: undefined }).getMany())
// console []
console.log(await repo.createQueryBuilder('table_a').where({ field_b: null }).getMany())
Currently, it's hard to check how many query has been affected, we can have a full test after the new UI release. Or
waiting for the https://github.com/typeorm/typeorm/issues/9316 conclusion then update typeorm. What do you think? @Keith-CY @WhiteMinds @homura
Currently, it's hard to check how many query has been affected, we can have a full test after the new UI release. Or waiting for the
https://github.com/typeorm/typeorm/issues/9316conclusion then update typeorm. What do you think?
There will likely be quite a bit of debate on this issue. I believe it is unlikely that TypeORM will revert to the old behavior unless some critical role of that old behavior is highlighted in the discussion.
BTW, I personally also prefer using approaches like isNULL, DATATYPE.NULL / DATATYPE.INTEGER etc to distinguish database types from JS native types, avoiding conflating their intent.
So I suggest we migrate to the new behavior, but do try to handle places that may be impacted, like hash: string | null | undefined, as much as possible at static code authoring time.
We could consider some actions to reduce the psychological burden of migrating from old to new behavior, such as temporarily (or permanently) removing null | undefined from the accepted value types in findOpts, using TS to provide cues, and enforcing no implicit any and checking explicit any to ensure proper type checking.
We could also consider patching TypeORM to report (just code locations) to something like Sentry when it receives null | undefined in findOpts, to quickly respond to unexpected errors.
It's ready for review now. Please have a review. @Keith-CY @homura @devchenyan @WhiteMinds
Conflicted
@silySuper now focuses on other issues, I'd suggest merging this one first and verify it in a regression test.
/package Packaging for test is done in 8462022029. @silySuper
https://github.com/yanguoyu/neuron/blob/d9a1d9b8e2ed22e6bcd173a1ab0a2c3aa40fdce0/packages/neuron-wallet/src/services/cell-local-info.ts#L31
@yanguoyu Regression testing found problems, not fully replaced.
1.When the remaining amount is 0,amend page shows 0 total amount,in expect it should be equal to amount in left.
2.In customized assets page ,when claim a histoty asset,it shows error(The same error shows when create asset account)
https://github.com/yanguoyu/neuron/blob/d9a1d9b8e2ed22e6bcd173a1ab0a2c3aa40fdce0/packages/neuron-wallet/src/services/cell-local-info.ts#L31
@yanguoyu Regression testing found problems, not fully replaced.
I guess findOne also works well.
1.When the remaining amount is 0,amend page shows 0 total amount,in expect it should be equal to amount in left.
2.In customized assets page ,when claim a histoty asset,it shows error(The same error shows when create asset account)
![]()
There may be some problems with your SQLite file. Could you rebuild the SQLite file with the release version and then test with this PR? Could you upload your SQLite file then I will check whether typeorm cannot connect your SQLite file.
1.When the remaining amount is 0,amend page shows 0 total amount,in expect it should be equal to amount in left.
2.In customized assets page ,when claim a histoty asset,it shows error(The same error shows when create asset account)
There may be some problems with your SQLite file. Could you rebuild the SQLite file with the release version and then test with this PR? Could you upload your SQLite file then I will check whether
typeormcannot connect your SQLite file.
Another package I download yesterday can claim successfully.I do not change any file relate to sqlite manually.
https://github.com/nervosnetwork/neuron/assets/25971273/725146dc-4ad9-4ed1-9b77-f1a7adbe8830
This is my sqlite : cells.zip
Another package I download yesterday can claim successfully.I do not change any file relate to sqlite manually.
I'm not sure whether your local SQLite file is migrated by Neuron, Could you upload the main.log?
Besides, you can back up the SQLite files and then delete these files to test run by creating a new local file.
Besides, you can back up the SQLite files and then delete these files to test run by creating a new local file.
Ok,this operation will sync from 0%,I am waiting it to sync 100%
This PR https://github.com/typeorm/typeorm/pull/9751/files#diff-4cfd478e52f9edd89cf748e00253bfb16a436f300c5c93404739a51433edca1aR39-R47 change the query slow log to warn, so I copy the Logger from typeorm and change console.warn to console.info
After open the neuron and turn off the computer at the same time for a long time,the log shows [error] Sync:ChildProcess: query is slow: SELECT "tx"."hash" AS "tx_hash", "tx"."version" AS "tx_version", "tx"."cellDeps" AS "tx_cellDeps", "tx"."headerDeps" AS "tx_headerDeps", "tx"."witnesses" AS "tx_witnesses", "tx"."timestamp" AS "tx_timestamp", "tx"."blockNumber" AS "tx_blockNumber", "tx"."blockHash" AS "tx_blockHash", "tx"."description" AS "tx_description", "tx"."status" AS "tx_status", "tx"."createdAt" AS "tx_createdAt", "tx"."updatedAt" AS "tx_updatedAt", "tx"."confirmed" AS "tx_confirmed" FROM "transaction" "tx" WHERE "tx"."status" = ? -- PARAMETERS: ["pending"] execution time: 48
Any update on this PR
/package Packaging for test is done in 9030541323. @Keith-CY
/package Packaging for test is done in 9030541323. @Keith-CY
Verified, could be merged first and tested again by @silySuper in regression tests.

2.In customized assets page ,when claim a histoty asset,it shows error(The same error shows when create asset account)