fix(store): properly generate IN clause for stored queries

This commit is contained in:
Václav Pavlín 2023-12-14 08:44:50 +01:00
parent 385daf16be
commit 5da7b22734
No known key found for this signature in database
GPG Key ID: B378FB31BB6D89A5

View File

@ -317,6 +317,9 @@ proc getMessagesPreparedStmt(s: PostgresDriver,
## prepared statements.
##
## contentTopic - string with list of conten topics. e.g: "'ctopic1','ctopic2','ctopic3'"
##
warn "Conntent topics joined", topic=contentTopic
var rows: seq[(PubsubTopic, WakuMessage, seq[byte], Timestamp)]
proc rowCallback(pqResult: ptr PGresult) =
@ -394,7 +397,7 @@ method getMessages*(s: PostgresDriver,
endTime.isSome():
## Considered the most common query. Therefore, we use prepared statements to optimize it.
return await s.getMessagesPreparedStmt(contentTopicSeq.join(","),
return await s.getMessagesPreparedStmt("'" & contentTopicSeq.join("','") & "'",
PubsubTopic(pubsubTopic.get()),
cursor,
startTime.get(),