I am trying to get list of items where deletedAt Column isNotNull but typeorm is returning where condition for deletedAt Column
Typeorm
const query = Results.createQueryBuilder('results');
query.where('results.deletedAt IS NOT NULL');
query.skip(page * limit);
query.take(limit);
console.log(query.getQuery());
return query.getManyAndCount();
it returns SQL Query as below
SELECT "results"."id" AS "results_id", "results"."date" AS "results_date", "results"."shift" AS "results_shift", "results"."result" AS "results_result", "results"."createdAt" AS "results_createdAt", "results"."updatedAt" AS "results_updatedAt", "results"."deletedAt" AS "results_deletedAt" FROM "results" "results" WHERE ( "results"."deletedAt" IS NOT NULL ) AND ( "results"."deletedAt" IS NULL ) LIMIT 10
Packages
"typeorm": "^0.3.7"
"@nestjs/typeorm": "^8.1.4",
"@nestjs/common": "^8.0.0",
CodePudding user response:
I guess results
entity has a @DeleteDateColumn
in it? If yes, the IS NULL
part will be automatically applied, plus the one you've entered manually.