fix: preserve NUL characters in persisted messages
Skeleton contracts / contracts (pull_request) Canceled after 0s
Application / smoke (pull_request) Canceled after 0s

Store message text as UTF-8 bytes and migrate existing rows without loss.
Cover HTTP round trips, restart persistence, Unicode limits and idempotent retries.
Adapt direct database tools to the binary storage format.
This commit is contained in:
Самохвалов Андрей Ремович
2026-11-07 09:53:39 +03:00
parent b3dae2855f
commit 3862765327
7 changed files with 169 additions and 7 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ def main():
with connection() as conn:
conn.execute(
"INSERT INTO messages (id,chat_id,sender_id,text,created_at) "
"SELECT gen_random_uuid(), %s, %s, 'synthetic-' || n, "
"SELECT gen_random_uuid(), %s, %s, convert_to('synthetic-' || n, 'UTF8'), "
"%s::timestamptz + n * interval '1 microsecond' "
"FROM generate_series(1,%s) AS n",
(chat["id"], user["id"], base, args.count),
+2 -2
View File
@@ -50,7 +50,7 @@ def main():
for name, size, chat_id in chats:
conn.execute(
"INSERT INTO messages (id,chat_id,sender_id,text,created_at) "
"SELECT gen_random_uuid(),%s,%s,%s || n,%s::timestamptz + n * interval '1 microsecond' "
"SELECT gen_random_uuid(),%s,%s,convert_to(%s || n, 'UTF8'),%s::timestamptz + n * interval '1 microsecond' "
"FROM generate_series(1,%s) n",
(chat_id, user["id"], name + "-synthetic-", base, size),
)
@@ -107,7 +107,7 @@ def main():
with conn.transaction():
conn.execute(
"INSERT INTO messages (id,chat_id,sender_id,text,created_at) "
"SELECT gen_random_uuid(),%s,%s,'write-synthetic-' || n,"
"SELECT gen_random_uuid(),%s,%s,convert_to('write-synthetic-' || n, 'UTF8'),"
"clock_timestamp() + n * interval '1 microsecond' "
"FROM generate_series(1,500) n",
(write_chat, user["id"]),