Skip to content

Commit

Permalink
Merge branch 'master' into fix_postgres_keyerror
Browse files Browse the repository at this point in the history
  • Loading branch information
aminalaee committed Jun 23, 2022
2 parents 338b6ea + c877098 commit dfef796
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## 0.6.0 (May 29th, 2022)

* Dropped Python 3.6 support (#458)

### Added

* Add _mapping property to the result set interface (#447 )
* Add contributing docs (#453 )

### Fixed

* Fix query result named access (#448)
* Fix connections getting into a bad state when a task is cancelled (#457)
* Revert #328 parallel transactions (#472)
* Change extra installations to specific drivers (#436)

## 0.5.4 (January 14th, 2022)

### Added
Expand Down
2 changes: 1 addition & 1 deletion databases/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from databases.core import Database, DatabaseURL

__version__ = "0.5.4"
__version__ = "0.6.0"
__all__ = ["Database", "DatabaseURL"]
9 changes: 6 additions & 3 deletions databases/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ def _build_query(
return query


_CallableType = typing.TypeVar("_CallableType", bound=typing.Callable)


class Transaction:
def __init__(
self,
Expand Down Expand Up @@ -347,13 +350,13 @@ async def __aexit__(
else:
await self.commit()

def __await__(self) -> typing.Generator:
def __await__(self) -> typing.Generator[None, None, "Transaction"]:
"""
Called if using the low-level `transaction = await database.transaction()`
"""
return self.start().__await__()

def __call__(self, func: typing.Callable) -> typing.Callable:
def __call__(self, func: _CallableType) -> _CallableType:
"""
Called if using `@database.transaction()` as a decorator.
"""
Expand All @@ -363,7 +366,7 @@ async def wrapper(*args: typing.Any, **kwargs: typing.Any) -> typing.Any:
async with self:
return await func(*args, **kwargs)

return wrapper
return wrapper # type: ignore

async def start(self) -> "Transaction":
self._connection = self._connection_callable()
Expand Down

0 comments on commit dfef796

Please sign in to comment.