Skip to content

Commit 1d630c4

Browse files
committed
fix(psqlpy): restore json_passthrough=True for native JSONB binding
Psqlpy's native bindings require Python dicts for JSONB columns. Without json_passthrough=True, the queue backend serializes dicts to JSON strings, causing "PyJSON must be dict or list value" errors.
1 parent 106db1c commit 1d630c4

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

sqlspec/adapters/psqlpy/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,4 +275,4 @@ def get_signature_namespace(self) -> "dict[str, Any]":
275275
def get_event_runtime_hints(self) -> "EventRuntimeHints":
276276
"""Return LISTEN/NOTIFY defaults for Psqlpy adapters."""
277277

278-
return EventRuntimeHints(poll_interval=0.5, select_for_update=True, skip_locked=True)
278+
return EventRuntimeHints(poll_interval=0.5, select_for_update=True, skip_locked=True, json_passthrough=True)

tests/unit/test_extensions/test_events/test_backend_factories.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ def test_psqlpy_factory_hybrid_backend() -> None:
139139
assert backend.backend_name == "listen_notify_durable"
140140

141141

142-
def test_psqlpy_factory_json_passthrough_not_set_by_default() -> None:
143-
"""Psqlpy hybrid backend does not enable json_passthrough by default.
142+
def test_psqlpy_factory_json_passthrough_enabled_by_default() -> None:
143+
"""Psqlpy hybrid backend enables json_passthrough by default.
144144
145-
This ensures consistency with other PostgreSQL adapters (asyncpg, psycopg)
146-
which also don't enable json_passthrough by default.
145+
Psqlpy's native bindings expect Python dicts for JSONB columns,
146+
so json_passthrough must be enabled to avoid serializing to strings.
147147
"""
148148
pytest.importorskip("psqlpy")
149149
from sqlspec.adapters.psqlpy.config import PsqlpyConfig
@@ -153,7 +153,7 @@ def test_psqlpy_factory_json_passthrough_not_set_by_default() -> None:
153153
backend = create_event_backend(config, "listen_notify_durable", {})
154154
assert backend is not None
155155
queue = backend._queue._queue # type: ignore[union-attr]
156-
assert queue._json_passthrough is False
156+
assert queue._json_passthrough is True
157157

158158

159159
def test_psqlpy_factory_json_passthrough_explicit() -> None:

0 commit comments

Comments
 (0)