@@ -3,7 +3,7 @@ import { Injectable, InternalServerErrorException, Logger } from '@nestjs/common
3
3
import { Database } from 'src/modules/database/models/database' ;
4
4
import apiConfig from 'src/utils/config' ;
5
5
import { ConnectionOptions } from 'tls' ;
6
- import { isEmpty , isNumber } from 'lodash' ;
6
+ import { isEmpty , isNumber , set } from 'lodash' ;
7
7
import { cloneClassInstance , generateRedisConnectionName } from 'src/utils' ;
8
8
import { ConnectionType } from 'src/modules/database/entities/database.entity' ;
9
9
import { ClientMetadata } from 'src/common/models' ;
@@ -212,7 +212,10 @@ export class RedisConnectionFactory {
212
212
// since ioredis doesn't handle "select" command error during connection
213
213
if ( dbIndex > 0 ) {
214
214
connection . select ( dbIndex )
215
- . then ( ( ) => resolve ( connection ) )
215
+ . then ( ( ) => {
216
+ set ( connection , [ 'options' , 'db' ] , dbIndex ) ;
217
+ resolve ( connection ) ;
218
+ } )
216
219
. catch ( reject ) ;
217
220
} else {
218
221
resolve ( connection ) ;
@@ -283,7 +286,10 @@ export class RedisConnectionFactory {
283
286
// since ioredis doesn't handle "select" command error during connection
284
287
if ( config . redisOptions . db > 0 ) {
285
288
connection . select ( config . redisOptions . db )
286
- . then ( ( ) => resolve ( connection ) )
289
+ . then ( ( ) => {
290
+ set ( connection , [ 'options' , 'db' ] , config . redisOptions . db ) ;
291
+ resolve ( connection ) ;
292
+ } )
287
293
. catch ( reject ) ;
288
294
} else {
289
295
resolve ( connection ) ;
@@ -343,7 +349,10 @@ export class RedisConnectionFactory {
343
349
// since ioredis doesn't handle "select" command error during connection
344
350
if ( config . db > 0 ) {
345
351
connection . select ( config . db )
346
- . then ( ( ) => resolve ( connection ) )
352
+ . then ( ( ) => {
353
+ set ( connection , [ 'options' , 'db' ] , config . db ) ;
354
+ resolve ( connection ) ;
355
+ } )
347
356
. catch ( reject ) ;
348
357
} else {
349
358
resolve ( connection ) ;
0 commit comments