From e08eb4f4fa78e72187d5d5c610ef47e07601a3c1 Mon Sep 17 00:00:00 2001 From: ansipunk Date: Sun, 3 Mar 2024 14:03:56 +0500 Subject: [PATCH] S01E06 --- databases/backends/common/records.py | 4 ++++ databases/backends/psycopg.py | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/databases/backends/common/records.py b/databases/backends/common/records.py index 65032fc8..5c7ae25c 100644 --- a/databases/backends/common/records.py +++ b/databases/backends/common/records.py @@ -1,4 +1,5 @@ import typing +from collections import namedtuple from sqlalchemy.engine.interfaces import Dialect from sqlalchemy.engine.row import Row as SQLRow @@ -39,6 +40,9 @@ def __init__( @property def _mapping(self) -> typing.Mapping: + if hasattr(self._row, "_asdict"): + return self._row._asdict() + return self._row def keys(self) -> typing.KeysView: diff --git a/databases/backends/psycopg.py b/databases/backends/psycopg.py index 3392a54b..302f94e5 100644 --- a/databases/backends/psycopg.py +++ b/databases/backends/psycopg.py @@ -168,7 +168,10 @@ def raw_connection(self) -> typing.Any: def _compile( self, query: ClauseElement, ) -> typing.Tuple[str, typing.Mapping[str, typing.Any], tuple]: - compiled = query.compile(dialect=self._dialect) + compiled = query.compile( + dialect=self._dialect, + compile_kwargs={"render_postcompile": True}, + ) compiled_query = compiled.string params = compiled.params