File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -125,7 +125,9 @@ export class RedisQueryResultCache implements QueryResultCache {
125125 options : QueryResultCacheOptions ,
126126 queryRunner ?: QueryRunner ,
127127 ) : Promise < QueryResultCacheOptions | undefined > {
128- const key = options . identifier ?? options . query
128+ const identifier =
129+ options . identifier === "" ? undefined : options . identifier
130+ const key = identifier ?? options . query
129131 if ( ! key ) return undefined
130132
131133 const result = await this . client . get ( key )
@@ -153,7 +155,9 @@ export class RedisQueryResultCache implements QueryResultCache {
153155 savedCache : QueryResultCacheOptions ,
154156 queryRunner ?: QueryRunner ,
155157 ) : Promise < void > {
156- const key = options . identifier ?? options . query
158+ const identifier =
159+ options . identifier === "" ? undefined : options . identifier
160+ const key = identifier ?? options . query
157161 if ( ! key ) return
158162
159163 const value = JSON . stringify ( options )
Original file line number Diff line number Diff line change @@ -179,6 +179,8 @@ export class DriverUtils {
179179 if ( afterBase && afterBase . indexOf ( "?" ) !== - 1 ) {
180180 afterBase = afterBase . substring ( 0 , afterBase . indexOf ( "?" ) )
181181 }
182+ // normalize empty string to undefined so downstream ?? works correctly
183+ if ( afterBase === "" ) afterBase = undefined
182184
183185 const lastAtSign = base . lastIndexOf ( "@" )
184186 const usernameAndPassword = base . substring ( 0 , lastAtSign )
@@ -217,6 +219,8 @@ export class DriverUtils {
217219 secondSlash !== - 1 ? preBase . substring ( 0 , secondSlash ) : preBase
218220 let afterBase =
219221 secondSlash !== - 1 ? preBase . substring ( secondSlash + 1 ) : undefined
222+ // normalize empty string to undefined so downstream ?? works correctly
223+ if ( afterBase === "" ) afterBase = undefined
220224 let afterQuestionMark : string
221225 let host = undefined
222226 let port = undefined
Original file line number Diff line number Diff line change @@ -3854,12 +3854,9 @@ export class SelectQueryBuilder<Entity extends ObjectLiteral>
38543854 : { }
38553855 let savedQueryResultCacheOptions : QueryResultCacheOptions | undefined =
38563856 undefined
3857- const isCachingEnabled =
3858- // Caching is enabled globally and isn't disabled locally.
3859- ( cacheOptions . alwaysEnabled &&
3860- this . expressionMap . cache !== false ) ??
3861- // ...or it's enabled locally explicitly.
3862- this . expressionMap . cache === true
3857+ const isCachingEnabled = cacheOptions . alwaysEnabled
3858+ ? this . expressionMap . cache !== false
3859+ : this . expressionMap . cache === true
38633860 let cacheError = false
38643861 if ( this . dataSource . queryResultCache && isCachingEnabled ) {
38653862 try {
You can’t perform that action at this time.
0 commit comments