fix: overriding caching settings when alwaysEnabled is true (#9731)

* 9023-2 Fix cache overriding option

* 9023-2 Fix format
This commit is contained in:
Pavel Kolpakov 2023-01-28 18:52:00 +04:00 committed by GitHub
parent ef64bfc6c5
commit 4df969ea62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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(
@ -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(