Skip to content

Commit bbbf6dc

Browse files
committed
fix sqlite query
1 parent 275cb2a commit bbbf6dc

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

tests/waku_archive/test_driver_sqlite.nim

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ suite "SQLite driver":
3232
test "insert a message":
3333
## Given
3434
const contentTopic = "test-content-topic"
35+
const meta = "test meta"
3536

3637
let driver = newSqliteArchiveDriver()
3738

38-
let msg = fakeWakuMessage(contentTopic = contentTopic)
39+
let msg = fakeWakuMessage(contentTopic = contentTopic, meta = meta)
3940
let msgHash = computeMessageHash(DefaultPubsubTopic, msg)
4041

4142
## When
@@ -51,9 +52,9 @@ suite "SQLite driver":
5152
check:
5253
storedMsg.len == 1
5354
storedMsg.all do(item: auto) -> bool:
54-
let (pubsubTopic, msg, _, _, hash) = item
55-
msg.contentTopic == contentTopic and pubsubTopic == DefaultPubsubTopic and
56-
hash == msgHash
55+
let (pubsubTopic, actualMsg, _, _, hash) = item
56+
actualMsg.contentTopic == contentTopic and pubsubTopic == DefaultPubsubTopic and
57+
hash == msgHash and msg.meta == actualMsg.meta
5758

5859
## Cleanup
5960
(waitFor driver.close()).expect("driver to close")

waku/waku_archive/driver/sqlite_driver/queries.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ proc insertMessageQuery(table: string): SqlQueryStr =
149149
return
150150
"INSERT INTO " & table &
151151
"(id, messageHash, storedAt, contentTopic, payload, pubsubTopic, version, timestamp, meta)" &
152-
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, CASE WHEN ? = '' THEN NULL ELSE ? END);"
152+
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);"
153153

154154
proc prepareInsertMessageStmt*(
155155
db: SqliteDatabase

0 commit comments

Comments
 (0)