Skip to content

fixes in ydb.aio library #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.7.0 ##

* fixes in TxContext in ydb.aio module.

## 2.6.0 ##

* support `with_native_interval_in_result_sets` flag in the table client.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setuptools.setup(
name="ydb",
version="2.6.0",
version="2.7.0",
description="YDB Python SDK",
author="Yandex LLC",
author_email="ydb@yandex-team.ru",
Expand Down
38 changes: 38 additions & 0 deletions tests/aio/test_tx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import pytest


@pytest.mark.asyncio
async def test_tx_commit(driver, database):
session = await driver.table_client.session().create()
prepared = await session.prepare(
"DECLARE $param as Int32;\n SELECT $param as value",
)

tx = session.transaction()
await tx.execute(prepared, {"$param": 2})
await tx.commit()
await tx.commit()


@pytest.mark.asyncio
async def test_tx_rollback(driver, database):
session = await driver.table_client.session().create()
prepared = await session.prepare(
"DECLARE $param as Int32;\n SELECT $param as value",
)

tx = session.transaction()
await tx.execute(prepared, {"$param": 2})
await tx.rollback()
await tx.rollback()


@pytest.mark.asyncio
async def test_tx_begin(driver, database):
session = await driver.table_client.session().create()
await session.create()

tx = session.transaction()
await tx.begin()
await tx.begin()
await tx.rollback()
20 changes: 16 additions & 4 deletions ydb/aio/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ async def keep_alive(self, settings=None): # pylint: disable=W0236
return await super().keep_alive(settings)

async def create(self, settings=None): # pylint: disable=W0236
return await super().create(settings)
res = super().create(settings)
if asyncio.iscoroutine(res):
res = await res
return res

async def delete(self, settings=None): # pylint: disable=W0236
return await super().delete(settings)
Expand Down Expand Up @@ -184,13 +187,22 @@ async def execute(
return await super().execute(query, parameters, commit_tx, settings)

async def commit(self, settings=None): # pylint: disable=W0236
return await super().commit(settings)
res = super().commit(settings)
if asyncio.iscoroutine(res):
res = await res
return res

async def rollback(self, settings=None): # pylint: disable=W0236
return await super().rollback(settings)
res = super().rollback(settings)
if asyncio.iscoroutine(res):
res = await res
return res

async def begin(self, settings=None): # pylint: disable=W0236
return await super().begin(settings)
res = super().begin(settings)
if asyncio.iscoroutine(res):
res = await res
return res


async def retry_operation(
Expand Down
2 changes: 1 addition & 1 deletion ydb/ydb_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "2.6.0"
VERSION = "2.7.0"