Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,11 @@ export class DataAccessObjectRedis extends BasicDataAccessObject implements IDat

private async getUsualConnection(): Promise<RedisClientType> {
let client: RedisClientType = LRUStorage.getRedisClientCache(this.connection);
const database = this.connection.database
? Number(this.connection.database)
? Number(this.connection.database)
: 0
: 0;
Comment on lines +699 to +703

Copilot AI Nov 20, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nested ternary logic for database conversion is flawed. When this.connection.database is "0", Number("0") evaluates to 0 (falsy), causing the condition on line 700 to fail and incorrectly fall through to the default value of 0 on line 702.

This should be simplified to properly handle the conversion:

const database = this.connection.database ? Number(this.connection.database) : 0;

Or if you need to handle invalid numeric strings:

const parsedDb = Number(this.connection.database);
const database = !isNaN(parsedDb) ? parsedDb : 0;
Suggested change
const database = this.connection.database
? Number(this.connection.database)
? Number(this.connection.database)
: 0
: 0;
const parsedDb = Number(this.connection.database);
const database = !isNaN(parsedDb) ? parsedDb : 0;

Copilot uses AI. Check for mistakes.
if (!client) {
client = createClient({
socket: {
Expand All @@ -706,6 +711,8 @@ export class DataAccessObjectRedis extends BasicDataAccessObject implements IDat
rejectUnauthorized: this.connection.ssl === false ? false : true,
},
password: this.connection.password || undefined,
username: this.connection.username || undefined,
database: database,
});
await client.connect();
LRUStorage.setRedisClientCache(this.connection, client);
Expand Down
Loading