Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

Commit 77270d8

Browse files
Allow string indexing into Record (#501)
* Allow string indexing into Record The Record interface inherits from Sequence which only supports integer indexing. The Postgres backend supports string indexing into Records (https://github.com/encode/databases/blob/master/databases/backends/postgres.py#L135). This PR updates the interface to reflect that. At least on the Postgres backend __getitem__ deserializes some data types, so it's not equivalent to the _mapping method.
1 parent 6a52a4a commit 77270d8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

databases/interfaces.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,6 @@ class Record(Sequence):
7373
@property
7474
def _mapping(self) -> typing.Mapping:
7575
raise NotImplementedError() # pragma: no cover
76+
77+
def __getitem__(self, key: typing.Any) -> typing.Any:
78+
raise NotImplementedError() # pragma: no cover

0 commit comments

Comments
 (0)