fix: pgAdapter maybeSingle, jsonb serialization for chat messages

↗ view on GitHub · Glauco · 2026-05-10 · 88fd998d

Three bugs in local/Docker mode:

1. PgAdapter.maybeSingle() returned the full rows array instead of a
   single row because _run() only checked _singleMode, not
   _maybeSingleMode. All routes using maybeSingle() got an array back
   and treated it as "not found" → "Chat not found" on every POST /chat.

2. JavaScript arrays passed to pg as query parameters are formatted as
   PostgreSQL array literals {a,b} which is invalid for jsonb columns.
   Fixed in PgAdapter insert/update to JSON.stringify arrays before
   binding.

3. Plain strings inserted into jsonb columns (chat_messages.content for
   user messages) are not valid JSON, causing the INSERT to fail
   silently. Fixed by JSON.stringify-ing string content in chat.ts,
   projectChat.ts and tabular.ts before the INSERT.

Also added missing `workflow jsonb` column to chat_messages in both
init.sql and schema.sql - the backend was already inserting this field.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Repository rglauco/mike
Author Glauco <37829079+rglauco@users.noreply.github.com>
Authored
Parents 139ce362
Stats 6 files changed , +25 , -5
Part of Docker Compose + Local Postgres (Supabase-Optional Mode)

Capture this commit into my fork

Download a Markdown prompt that tells Claude how to port this exact commit into your working tree. Run it via claude -p < capture-commit-88fd998d.md from inside the repo you want the change in.

⬇ Download capture-commit-88fd998d.md