Skip to content

Commit 8b09c0f

Browse files
committed
inserting meta field null when there's an empty string
1 parent 2d3dcfa commit 8b09c0f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

waku/waku_archive/driver/postgres_driver/postgres_driver.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type PostgresDriver* = ref object of ArchiveDriver
3131
const InsertRowStmtName = "InsertRow"
3232
const InsertRowStmtDefinition = # TODO: get the sql queries from a file
3333
"""INSERT INTO messages (id, messageHash, storedAt, contentTopic, payload, pubsubTopic,
34-
version, timestamp, meta) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) ON CONFLICT DO NOTHING;"""
34+
version, timestamp, meta) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, CASE WHEN $9 = '' THEN NULL ELSE $9 END) ON CONFLICT DO NOTHING;"""
3535

3636
const SelectNoCursorAscStmtName = "SelectWithoutCursorAsc"
3737
const SelectNoCursorAscStmtDef =

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 (?, ?, ?, ?, ?, ?, ?, ?, ?);"
152+
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, CASE WHEN ? = '' THEN NULL ELSE ? END);"
153153

154154
proc prepareInsertMessageStmt*(
155155
db: SqliteDatabase

0 commit comments

Comments
 (0)