Skip to content

Commit aebdf13

Browse files
committed
feat: allow to view tuples outside transactions
1 parent f984795 commit aebdf13

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/tgdb/application/relation/view_tuples.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ViewTuples:
2222

2323
async def __call__(
2424
self,
25-
xid: XID,
25+
xid: XID | None,
2626
relation_number: Number,
2727
attribute_number: Number,
2828
attribute_scalar: Scalar,
@@ -44,9 +44,10 @@ async def __call__(
4444
for versioned_tuple in versioned_tuples
4545
)
4646

47-
async with self.shared_horizon as horizon:
48-
for viewed_tuple_ in viewed_tuples:
49-
time = await self.clock
50-
horizon.include(time, xid, viewed_tuple_)
47+
if xid is not None:
48+
async with self.shared_horizon as horizon:
49+
for viewed_tuple_ in viewed_tuples:
50+
time = await self.clock
51+
horizon.include(time, xid, viewed_tuple_)
5152

5253
return tuples

src/tgdb/presentation/fastapi/relation/routers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414

1515
relation_routers = (
16-
create_relation_router,
1716
view_all_relations_router,
1817
view_relation_router,
18+
create_relation_router,
1919
view_tuples_router,
2020
)

src/tgdb/presentation/fastapi/relation/routes/view_tuples.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ def of(cls, tuples: Iterable[Tuple]) -> "ViewedTuplesSchema":
4545
},
4646
summary="View tuples",
4747
description="View tuples in an active transaction.",
48-
tags=[Tag.relation, Tag.transaction],
48+
tags=[Tag.relation],
4949
)
5050
@inject
5151
async def _(
5252
view_tuples: FromDishka[ViewTuples],
53-
xid: XID,
5453
relation_number: PositiveInt,
5554
attribute_number: Annotated[PositiveInt, Query(alias="attributeNumber")],
5655
attribute_scalar: Annotated[Scalar, Query(alias="attributeScalar")],
56+
xid: XID | None = None,
5757
) -> Response:
5858
tuples = await view_tuples(
5959
xid,

0 commit comments

Comments
 (0)