'TypeORM relationquerybuilder of remove with Not(IsNull()) not removing anything
Good day everyone,
I ran into a strange problem with typeORM. I have a many-to-many relation on Offer with User named pending, which creates a table offer_pending_user that looks like:
| userId | offerId |
|---|---|
| 0 | 1 |
| 1 | 0 |
I basically want to completely clear this table. I tried to achieve this by using the RelationQueryBuilder like follows:
await Offer.createQueryBuilder()
.relation("pending")
.of({ id: Not(IsNull()) }) //offer id
.remove({ id: Not(IsNull()) }); //user id
For some reason. It does not clear the offer_pending_user table at all. The query that it is executing looks like:
DELETE FROM "offer_pending_user" WHERE ("offerId" = ? AND "userId" = ?) -- PARAMETERS:
[{
"_type":"not",
"_value": {
"_type":"isNull",
"_useParameter":false,
"_multipleParameters":false
},
"_useParameter":true,
"_multipleParameters":false
},{
"_type":"not",
"_value": {
"_type":"isNull",
"_useParameter":false,
"_multipleParameters":false
},
"_useParameter":true,
"_multipleParameters":false
}]
I would like to use this RelationQueryBuilder, and would like to know what I'm missing here.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
