From efb649724c533e625ad381f36cd3f027c1260555 Mon Sep 17 00:00:00 2001 From: Rickert Mulder Date: Mon, 15 Aug 2022 12:07:53 +0200 Subject: [PATCH] Ensure __getattr__ matches __getitem__'s behaviour The `__getitem__` function does extra deserialisation that's not happening in __getattr__. As an example referencing a JSONB field with __getitem__ gets you a `dict` whereas `__getattr__` results in a `str`. This PR aligns their behaviour. --- databases/backends/postgres.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/databases/backends/postgres.py b/databases/backends/postgres.py index 3e1a6fff..87b73d11 100644 --- a/databases/backends/postgres.py +++ b/databases/backends/postgres.py @@ -155,7 +155,7 @@ def __len__(self) -> int: return len(self._row) def __getattr__(self, name: str) -> typing.Any: - return self._mapping.get(name) + return self.__getitem__(name) class PostgresConnection(ConnectionBackend):