@@ -59,14 +59,16 @@ export class PostgresDatabaseAdapter
59
59
while ( retryCount < maxRetries ) {
60
60
try {
61
61
const delay = baseDelay * Math . pow ( 2 , retryCount ) ;
62
- elizaLogger . log ( `Attempting to reconnect in ${ delay } ms...` ) ;
62
+ elizaLogger . warn (
63
+ `Attempting to reconnect in ${ delay } ms...`
64
+ ) ;
63
65
await new Promise ( ( resolve ) => setTimeout ( resolve , delay ) ) ;
64
66
65
67
// Create new pool with same config
66
68
this . pool = new pg . Pool ( this . pool . options ) ;
67
69
await this . testConnection ( ) ;
68
70
69
- elizaLogger . log ( "Successfully reconnected to database" ) ;
71
+ elizaLogger . success ( "Successfully reconnected to database" ) ;
70
72
return ;
71
73
} catch ( error ) {
72
74
retryCount ++ ;
@@ -116,7 +118,7 @@ export class PostgresDatabaseAdapter
116
118
try {
117
119
client = await this . pool . connect ( ) ;
118
120
const result = await client . query ( "SELECT NOW()" ) ;
119
- elizaLogger . log (
121
+ elizaLogger . success (
120
122
"Database connection test successful:" ,
121
123
result . rows [ 0 ]
122
124
) ;
@@ -215,7 +217,7 @@ export class PostgresDatabaseAdapter
215
217
if ( rows . length === 0 ) return null ;
216
218
217
219
const account = rows [ 0 ] ;
218
- elizaLogger . log ( "account" , account ) ;
220
+ elizaLogger . debug ( "account" , account ) ;
219
221
return {
220
222
...account ,
221
223
details :
@@ -346,7 +348,7 @@ export class PostgresDatabaseAdapter
346
348
if ( ! params . roomId ) throw new Error ( "roomId is required" ) ;
347
349
let sql = `SELECT * FROM memories WHERE type = $1 AND "agentId" = $2 AND "roomId" = $3` ;
348
350
const values : any [ ] = [ params . tableName , params . agentId , params . roomId ] ;
349
- let paramCount = 2 ;
351
+ let paramCount = 3 ; // Updated to start at 3 since we already have 3 parameters
350
352
351
353
if ( params . start ) {
352
354
paramCount ++ ;
@@ -366,9 +368,9 @@ export class PostgresDatabaseAdapter
366
368
367
369
sql += ' ORDER BY "createdAt" DESC' ;
368
370
369
- if ( params . count ) {
371
+ if ( params . count && typeof params . count === "number" ) {
370
372
paramCount ++ ;
371
- sql += ` LIMIT $${ paramCount } ` ;
373
+ sql += ` LIMIT $${ paramCount } ::integer` ; // Cast to integer
372
374
values . push ( params . count ) ;
373
375
}
374
376
@@ -628,7 +630,7 @@ export class PostgresDatabaseAdapter
628
630
) ;
629
631
630
632
if ( existingParticipant . rows . length > 0 ) {
631
- elizaLogger . log (
633
+ elizaLogger . error (
632
634
`Participant with userId ${ userId } already exists in room ${ roomId } .`
633
635
) ;
634
636
return true ; // Exit early if the participant already exists
@@ -643,7 +645,7 @@ export class PostgresDatabaseAdapter
643
645
return true ;
644
646
} catch ( error ) {
645
647
if ( error instanceof DatabaseError ) {
646
- elizaLogger . log ( "Error adding participant" , error ) ;
648
+ elizaLogger . error ( "Error adding participant" , error ) ;
647
649
// This is to prevent duplicate participant error in case of a race condition
648
650
// Handle unique constraint violation error (code 23505)
649
651
if ( error . code === "23505" ) {
0 commit comments