feat(redis): enhance connection setup with username and database handling#1441
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enhances Redis connection setup by adding support for username authentication and database selection. These additions align Redis connections with standard authentication patterns used by other database adapters in the codebase.
- Added
usernamefield to Redis client configuration for authentication - Added
databasefield to support Redis database selection (0-15) - Implemented database value parsing from connection parameters
Comments suppressed due to low confidence (1)
shared-code/src/data-access-layer/data-access-objects/data-access-object-redis.ts:666
- This guard always evaluates to false.
result = rowValue === null || rowValue === undefined || rowValue === '';
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const database = this.connection.database | ||
| ? Number(this.connection.database) | ||
| ? Number(this.connection.database) | ||
| : 0 | ||
| : 0; |
There was a problem hiding this comment.
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;| 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; |
No description provided.