Skip to content

Commit

Permalink
fix: overriding caching settings when alwaysEnabled is true (#9731)
Browse files Browse the repository at this point in the history
* 9023-2 Fix cache overriding option

* 9023-2 Fix format
  • Loading branch information
kolpakov-p committed Jan 28, 2023
1 parent ef64bfc commit 4df969e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/query-builder/SelectQueryBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3685,11 +3685,13 @@ export class SelectQueryBuilder<Entity extends ObjectLiteral>
: {}
let savedQueryResultCacheOptions: QueryResultCacheOptions | undefined =
undefined
const isCachingEnabled =
// Caching is enabled globally and isn't disabled locally.
(cacheOptions.alwaysEnabled && this.expressionMap.cache) ||
// ...or it's enabled locally explicitly.
this.expressionMap.cache
let cacheError = false
if (
this.connection.queryResultCache &&
(this.expressionMap.cache || cacheOptions.alwaysEnabled)
) {
if (this.connection.queryResultCache && isCachingEnabled) {
try {
savedQueryResultCacheOptions =
await this.connection.queryResultCache.getFromCache(
Expand Down Expand Up @@ -3724,7 +3726,7 @@ export class SelectQueryBuilder<Entity extends ObjectLiteral>
if (
!cacheError &&
this.connection.queryResultCache &&
(this.expressionMap.cache || cacheOptions.alwaysEnabled)
isCachingEnabled
) {
try {
await this.connection.queryResultCache.storeInCache(
Expand Down

0 comments on commit 4df969e

Please sign in to comment.