deadlinecode / baileys-bottle

56 stars 40 forks source link

QueryFailedError: there is no unique or exclusion constraint matching the ON CONFLICT #20

Open sahil30123 opened 1 year ago

sahil30123 commented 1 year ago

I'm currently trying to get updates of new members added to the group using group-participants.update , but in the meanwhile I'm receiving this error (on debug: true):

query: INSERT INTO "chat"("id", "messages", "newJid", "oldJid", "lastMsgTimestamp", "unreadCount", "readOnly", "endOfHistoryTransfer", "ephemera
lExpiration", "ephemeralSettingTimestamp", "endOfHistoryTransferType", "conversationTimestamp", "name", "pHash", "notSpam", "archived", "disappe
aringMode", "unreadMentionCount", "markedAsUnread", "participant", "tcToken", "tcTokenTimestamp", "contactPrimaryIdentityKey", "pinned", "muteEn
dTime", "wallpaper", "mediaVisibility", "tcTokenSenderTimestamp", "suspended", "terminated", "createdAt", "createdBy", "description", "support",
 "isParentGroup", "isDefaultSubgroup", "parentGroupId", "displayName", "pnJid", "selfMasked", "mute", "pin", "archive", "dBAuthId") VALUES ($1, 
DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, $2, $3, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, D
EFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, D
EFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, $4) ON CONFLICT ( "id", "dBAuthId" ) DO UPDATE SET "id" = EXCLUD
ED."id", "dBAuthId" = EXCLUDED."dBAuthId", "conversationTimestamp" = EXCLUDED."conversationTimestamp", "name" = EXCLUDED."name"  RETURNING "DBId" -- PARAMETERS: ["120363148309063612@g.us","1683136266","Jid",1]
query failed: INSERT INTO "chat"("id", "messages", "newJid", "oldJid", "lastMsgTimestamp", "unreadCount", "readOnly", "endOfHistoryTransfer", "e
phemeralExpiration", "ephemeralSettingTimestamp", "endOfHistoryTransferType", "conversationTimestamp", "name", "pHash", "notSpam", "archived", "
disappearingMode", "unreadMentionCount", "markedAsUnread", "participant", "tcToken", "tcTokenTimestamp", "contactPrimaryIdentityKey", "pinned", 
"muteEndTime", "wallpaper", "mediaVisibility", "tcTokenSenderTimestamp", "suspended", "terminated", "createdAt", "createdBy", "description", "su
pport", "isParentGroup", "isDefaultSubgroup", "parentGroupId", "displayName", "pnJid", "selfMasked", "mute", "pin", "archive", "dBAuthId") VALUE
S ($1, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, $2, $3, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEF
AULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEF
AULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, $4) ON CONFLICT ( "id", "dBAuthId" ) DO UPDATE SET "id" =
 EXCLUDED."id", "dBAuthId" = EXCLUDED."dBAuthId", "conversationTimestamp" = EXCLUDED."conversationTimestamp", "name" = EXCLUDED."name"  RETURNING "DBId" -- PARAMETERS: ["120363148309063612@g.us","1683136266","Jid",1]
error: error: there is no unique or exclusion constraint matching the ON CONFLICT specification
    at Parser.parseErrorMessage (C:\Users\hey\IdeaProjects\proj\node_modules\pg-protocol\dist\parser.js:287:98)
    at Parser.handlePacket (C:\Users\hey\IdeaProjects\proj\node_modules\pg-protocol\dist\parser.js:126:29)
    at Parser.parse (C:\Users\hey\IdeaProjects\proj\node_modules\pg-protocol\dist\parser.js:39:38)
    at TLSSocket.<anonymous> (C:\Users\hey\IdeaProjects\proj\node_modules\pg-protocol\dist\index.js:11:42)
    at TLSSocket.emit (node:events:513:28)
    at TLSSocket.emit (node:domain:489:12)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Readable.push (node:internal/streams/readable:234:10)
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)
    at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
  length: 148,
  severity: 'ERROR',
  code: '42P10',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'plancat.c',
  line: '861',
  routine: 'infer_arbiter_indexes'
}
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
QueryFailedError: there is no unique or exclusion constraint matching the ON CONFLICT specification
    at PostgresQueryRunner.query (C:\Users\hey\IdeaProjects\proj\node_modules\typeorm\driver\postgres\PostgresQueryRunner.js:211:19)      
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async InsertQueryBuilder.execute (C:\Users\hey\IdeaProjects\proj\node_modules\typeorm\query-builder\InsertQueryBuilder.js:106:33)

I'm experiencing this only on group-participants.update's "add" events but not on "remove" or other events like message.upsert.

NOTE: I'm using WhiskeySockets by using yarn add @adiwajshing/baileys@github:WhiskeySockets/Baileys , compiles it using tsc, and thereby replaces withbaileys-bottle/node_modules/@adiwajshing/baileys/. I'm using Postgres as my database type.

deadlinecode commented 1 year ago

Will take a look I will also need to update the package to use whiskey isntead of baileys

owuraku commented 2 months ago

Will take a look I will also need to update the package to use whiskey isntead of baileys

What ever happened to this bug ?

@sahil30123 did you find a solution?