This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# ext/asyncio/result.py
|
||||
# Copyright (C) 2020-2025 the SQLAlchemy authors and contributors
|
||||
# Copyright (C) 2020-2023 the SQLAlchemy authors and contributors
|
||||
# <see AUTHORS file>
|
||||
#
|
||||
# This module is part of SQLAlchemy and is released under
|
||||
@@ -93,7 +93,6 @@ class AsyncResult(_WithKeys, AsyncCommon[Row[_TP]]):
|
||||
|
||||
self._metadata = real_result._metadata
|
||||
self._unique_filter_state = real_result._unique_filter_state
|
||||
self._source_supports_scalars = real_result._source_supports_scalars
|
||||
self._post_creational_filter = None
|
||||
|
||||
# BaseCursorResult pre-generates the "_row_getter". Use that
|
||||
@@ -325,20 +324,22 @@ class AsyncResult(_WithKeys, AsyncCommon[Row[_TP]]):
|
||||
return await greenlet_spawn(self._only_one_row, True, False, False)
|
||||
|
||||
@overload
|
||||
async def scalar_one(self: AsyncResult[Tuple[_T]]) -> _T: ...
|
||||
async def scalar_one(self: AsyncResult[Tuple[_T]]) -> _T:
|
||||
...
|
||||
|
||||
@overload
|
||||
async def scalar_one(self) -> Any: ...
|
||||
async def scalar_one(self) -> Any:
|
||||
...
|
||||
|
||||
async def scalar_one(self) -> Any:
|
||||
"""Return exactly one scalar result or raise an exception.
|
||||
|
||||
This is equivalent to calling :meth:`_asyncio.AsyncResult.scalars` and
|
||||
then :meth:`_asyncio.AsyncScalarResult.one`.
|
||||
then :meth:`_asyncio.AsyncResult.one`.
|
||||
|
||||
.. seealso::
|
||||
|
||||
:meth:`_asyncio.AsyncScalarResult.one`
|
||||
:meth:`_asyncio.AsyncResult.one`
|
||||
|
||||
:meth:`_asyncio.AsyncResult.scalars`
|
||||
|
||||
@@ -348,20 +349,22 @@ class AsyncResult(_WithKeys, AsyncCommon[Row[_TP]]):
|
||||
@overload
|
||||
async def scalar_one_or_none(
|
||||
self: AsyncResult[Tuple[_T]],
|
||||
) -> Optional[_T]: ...
|
||||
) -> Optional[_T]:
|
||||
...
|
||||
|
||||
@overload
|
||||
async def scalar_one_or_none(self) -> Optional[Any]: ...
|
||||
async def scalar_one_or_none(self) -> Optional[Any]:
|
||||
...
|
||||
|
||||
async def scalar_one_or_none(self) -> Optional[Any]:
|
||||
"""Return exactly one scalar result or ``None``.
|
||||
|
||||
This is equivalent to calling :meth:`_asyncio.AsyncResult.scalars` and
|
||||
then :meth:`_asyncio.AsyncScalarResult.one_or_none`.
|
||||
then :meth:`_asyncio.AsyncResult.one_or_none`.
|
||||
|
||||
.. seealso::
|
||||
|
||||
:meth:`_asyncio.AsyncScalarResult.one_or_none`
|
||||
:meth:`_asyncio.AsyncResult.one_or_none`
|
||||
|
||||
:meth:`_asyncio.AsyncResult.scalars`
|
||||
|
||||
@@ -400,10 +403,12 @@ class AsyncResult(_WithKeys, AsyncCommon[Row[_TP]]):
|
||||
return await greenlet_spawn(self._only_one_row, True, True, False)
|
||||
|
||||
@overload
|
||||
async def scalar(self: AsyncResult[Tuple[_T]]) -> Optional[_T]: ...
|
||||
async def scalar(self: AsyncResult[Tuple[_T]]) -> Optional[_T]:
|
||||
...
|
||||
|
||||
@overload
|
||||
async def scalar(self) -> Any: ...
|
||||
async def scalar(self) -> Any:
|
||||
...
|
||||
|
||||
async def scalar(self) -> Any:
|
||||
"""Fetch the first column of the first row, and close the result set.
|
||||
@@ -447,13 +452,16 @@ class AsyncResult(_WithKeys, AsyncCommon[Row[_TP]]):
|
||||
@overload
|
||||
def scalars(
|
||||
self: AsyncResult[Tuple[_T]], index: Literal[0]
|
||||
) -> AsyncScalarResult[_T]: ...
|
||||
) -> AsyncScalarResult[_T]:
|
||||
...
|
||||
|
||||
@overload
|
||||
def scalars(self: AsyncResult[Tuple[_T]]) -> AsyncScalarResult[_T]: ...
|
||||
def scalars(self: AsyncResult[Tuple[_T]]) -> AsyncScalarResult[_T]:
|
||||
...
|
||||
|
||||
@overload
|
||||
def scalars(self, index: _KeyIndexType = 0) -> AsyncScalarResult[Any]: ...
|
||||
def scalars(self, index: _KeyIndexType = 0) -> AsyncScalarResult[Any]:
|
||||
...
|
||||
|
||||
def scalars(self, index: _KeyIndexType = 0) -> AsyncScalarResult[Any]:
|
||||
"""Return an :class:`_asyncio.AsyncScalarResult` filtering object which
|
||||
@@ -825,9 +833,11 @@ class AsyncTupleResult(AsyncCommon[_R], util.TypingOnly):
|
||||
"""
|
||||
...
|
||||
|
||||
def __aiter__(self) -> AsyncIterator[_R]: ...
|
||||
async def __aiter__(self) -> AsyncIterator[_R]:
|
||||
...
|
||||
|
||||
async def __anext__(self) -> _R: ...
|
||||
async def __anext__(self) -> _R:
|
||||
...
|
||||
|
||||
async def first(self) -> Optional[_R]:
|
||||
"""Fetch the first object or ``None`` if no object is present.
|
||||
@@ -861,20 +871,22 @@ class AsyncTupleResult(AsyncCommon[_R], util.TypingOnly):
|
||||
...
|
||||
|
||||
@overload
|
||||
async def scalar_one(self: AsyncTupleResult[Tuple[_T]]) -> _T: ...
|
||||
async def scalar_one(self: AsyncTupleResult[Tuple[_T]]) -> _T:
|
||||
...
|
||||
|
||||
@overload
|
||||
async def scalar_one(self) -> Any: ...
|
||||
async def scalar_one(self) -> Any:
|
||||
...
|
||||
|
||||
async def scalar_one(self) -> Any:
|
||||
"""Return exactly one scalar result or raise an exception.
|
||||
|
||||
This is equivalent to calling :meth:`_engine.Result.scalars`
|
||||
and then :meth:`_engine.AsyncScalarResult.one`.
|
||||
and then :meth:`_engine.Result.one`.
|
||||
|
||||
.. seealso::
|
||||
|
||||
:meth:`_engine.AsyncScalarResult.one`
|
||||
:meth:`_engine.Result.one`
|
||||
|
||||
:meth:`_engine.Result.scalars`
|
||||
|
||||
@@ -884,20 +896,22 @@ class AsyncTupleResult(AsyncCommon[_R], util.TypingOnly):
|
||||
@overload
|
||||
async def scalar_one_or_none(
|
||||
self: AsyncTupleResult[Tuple[_T]],
|
||||
) -> Optional[_T]: ...
|
||||
) -> Optional[_T]:
|
||||
...
|
||||
|
||||
@overload
|
||||
async def scalar_one_or_none(self) -> Optional[Any]: ...
|
||||
async def scalar_one_or_none(self) -> Optional[Any]:
|
||||
...
|
||||
|
||||
async def scalar_one_or_none(self) -> Optional[Any]:
|
||||
"""Return exactly one or no scalar result.
|
||||
|
||||
This is equivalent to calling :meth:`_engine.Result.scalars`
|
||||
and then :meth:`_engine.AsyncScalarResult.one_or_none`.
|
||||
and then :meth:`_engine.Result.one_or_none`.
|
||||
|
||||
.. seealso::
|
||||
|
||||
:meth:`_engine.AsyncScalarResult.one_or_none`
|
||||
:meth:`_engine.Result.one_or_none`
|
||||
|
||||
:meth:`_engine.Result.scalars`
|
||||
|
||||
@@ -905,12 +919,12 @@ class AsyncTupleResult(AsyncCommon[_R], util.TypingOnly):
|
||||
...
|
||||
|
||||
@overload
|
||||
async def scalar(
|
||||
self: AsyncTupleResult[Tuple[_T]],
|
||||
) -> Optional[_T]: ...
|
||||
async def scalar(self: AsyncTupleResult[Tuple[_T]]) -> Optional[_T]:
|
||||
...
|
||||
|
||||
@overload
|
||||
async def scalar(self) -> Any: ...
|
||||
async def scalar(self) -> Any:
|
||||
...
|
||||
|
||||
async def scalar(self) -> Any:
|
||||
"""Fetch the first column of the first row, and close the result
|
||||
|
||||
Reference in New Issue
Block a user