From e404243c522edf0ebf09b5a5905fec9225182ae1 Mon Sep 17 00:00:00 2001 From: rossmerr-technis <148052079+rossmerr-technis@users.noreply.github.com> Date: Mon, 13 May 2024 16:14:53 +0200 Subject: [PATCH] added json decoder --- src/opal_fetcher_postgres/provider.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/opal_fetcher_postgres/provider.py b/src/opal_fetcher_postgres/provider.py index b1ae087..01b2d35 100644 --- a/src/opal_fetcher_postgres/provider.py +++ b/src/opal_fetcher_postgres/provider.py @@ -5,6 +5,7 @@ """ from typing import Optional, List +import json import asyncpg from asyncpg.transaction import Transaction from asyncpg.exceptions import DataError @@ -139,6 +140,15 @@ async def __aenter__(self): self._connection: asyncpg.Connection = await asyncpg.connect( dsn, **connection_params ) + + # add support for json decoder + await self._connection.set_type_codec( + 'json', + encoder=json.dumps, + decoder=json.loads, + schema='pg_catalog' + ) + # start a readonly transaction (we don't want OPAL client writing data due to security!) self._transaction: Transaction = self._connection.transaction(readonly=True) await self._transaction.__aenter__()