Skip to content

Commit

Permalink
Allow string indexing into Record (#501)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
circlingthesun committed Aug 3, 2022
1 parent 6a52a4a commit 77270d8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions databases/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,6 @@ class Record(Sequence):
@property
def _mapping(self) -> typing.Mapping:
raise NotImplementedError() # pragma: no cover

def __getitem__(self, key: typing.Any) -> typing.Any:
raise NotImplementedError() # pragma: no cover

0 comments on commit 77270d8

Please sign in to comment.