Clients: define behavior for SQL-valid NULL event type/payload
Problem
Driver Message types assume type and/or payload are always non-null strings, but PgQue/PgQ low-level primitives can produce nullable ev_type / ev_data rows.
Examples:
- Go:
Message.Type string,Message.Payload string; scanning SQL NULL into these fields can fail. - TypeScript:
Message.type: string,payload: string; raw row mapping assumes non-null. - Python type hints/docs similarly imply concrete values, though psycopg may return
None.
SQL permits/directly supports lower-level producers such as insert_event(queue, null::text, null::text). Even if high-level send() normally supplies defaults/JSON, drivers expose raw received messages and should define behavior for SQL-valid events.
Why this matters
PgQue is explicitly a thin wrapper over PgQ primitives. Clients may consume queues populated by SQL or another language, not only by the same driver's high-level send().
Suggested fix
Decide one policy:
- Strict high-level API policy: document that drivers only support messages produced by PgQue high-level
send()and reject/null-check others with clear typed errors. - Robust PgQ-compatible policy: model nullable fields accurately:
- Go:
*stringorpgtype.TextforType/Payload - TypeScript:
string | null - Python:
Optional[str]/ payload optional
- Go:
Given PgQue's “thin wrapper over SQL primitives” stance, option 2 seems more honest.
Acceptance criteria
- Tests cover receiving a SQL-inserted event with NULL type/payload, or docs explicitly declare this unsupported.
- Type definitions match actual supported behavior.
Shipped in v0.3.0-rc.2 (merged to main via #395 at f4c7457): https://github.com/NikolayS/PgQue/releases/tag/v0.3.0-rc.2