]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Add depracation for old tuple methods
authorYurii Karabas <1998uriyyo@gmail.com>
Sat, 16 Dec 2023 14:15:44 +0000 (16:15 +0200)
committerYurii Karabas <1998uriyyo@gmail.com>
Sat, 16 Dec 2023 14:15:44 +0000 (16:15 +0200)
lib/sqlalchemy/engine/result.py
lib/sqlalchemy/engine/row.py
lib/sqlalchemy/ext/asyncio/result.py
lib/sqlalchemy/orm/query.py

index 2b9f0282cc7bc3e3a135cc2af1e5a7e78ab80c59..90c49a6705465661fab1ab0245547c2a8204d98b 100644 (file)
@@ -40,6 +40,7 @@ from .. import util
 from ..sql.base import _generative
 from ..sql.base import HasMemoized
 from ..sql.base import InPlaceGenerative
+from ..util import deprecated
 from ..util import HasMemoized_ro_memoized_attribute
 from ..util import NONE_SET
 from ..util._has_cy import HAS_CYEXTENSION
@@ -1232,6 +1233,11 @@ class Result(_WithKeys, ResultInternal[Row[Unpack[_Ts]]]):
         return MappingResult(self)
 
     @property
+    @deprecated(
+        "2.1.0",
+        "The :attr:`.Result.t` method is deprecated, :class:`.Row` "
+        "now behaves like a tuple and can unpack types directly.",
+    )
     def t(self) -> TupleResult[Tuple[Unpack[_Ts]]]:
         """Apply a "typed tuple" typing filter to returned rows.
 
@@ -1243,6 +1249,11 @@ class Result(_WithKeys, ResultInternal[Row[Unpack[_Ts]]]):
         """
         return self  # type: ignore
 
+    @deprecated(
+        "2.1.0",
+        "The :method:`.Result.tuples` method is deprecated, :class:`.Row` "
+        "now behaves like a tuple and can unpack types directly.",
+    )
     def tuples(self) -> TupleResult[Tuple[Unpack[_Ts]]]:
         """Apply a "typed tuple" typing filter to returned rows.
 
index e164b45a71b75e84e0fc838f2aec31b73d48c566..d2aa1c497e036615c43c5f815979981cf2938b27 100644 (file)
@@ -88,6 +88,11 @@ class Row(BaseRow, _RowBase[Unpack[_Ts]], Generic[Unpack[_Ts]]):
     def __delattr__(self, name: str) -> NoReturn:
         raise AttributeError("can't delete attribute")
 
+    @deprecated(
+        "2.1.0",
+        "The :meth:`.Row._tuple` method is deprecated, :class:`.Row` "
+        "now behaves like a tuple and can unpack types directly.",
+    )
     def _tuple(self) -> Tuple[Unpack[_Ts]]:
         """Return a 'tuple' form of this :class:`.Row`.
 
@@ -128,6 +133,11 @@ class Row(BaseRow, _RowBase[Unpack[_Ts]], Generic[Unpack[_Ts]]):
         return self._tuple()
 
     @property
+    @deprecated(
+        "2.1.0",
+        "The :attr:`.Row._t` attribute is deprecated, :class:`.Row` "
+        "now behaves like a tuple and can unpack types directly.",
+    )
     def _t(self) -> Tuple[Unpack[_Ts]]:
         """A synonym for :meth:`.Row._tuple`.
 
index 4c093aa17cfd0b37c9e1b5f6fce726389ec935d4..5467ed4c8fa3e923c53f6545cf9bd91c33b81b02 100644 (file)
@@ -28,6 +28,7 @@ from ...engine.result import ResultMetaData
 from ...engine.row import Row
 from ...engine.row import RowMapping
 from ...sql.base import _generative
+from ...util import deprecated
 from ...util.concurrency import greenlet_spawn
 from ...util.typing import Literal
 from ...util.typing import Self
@@ -105,6 +106,11 @@ class AsyncResult(_WithKeys, AsyncCommon[Row[Unpack[_Ts]]]):
             )
 
     @property
+    @deprecated(
+        "2.1.0",
+        "The :attr:`.AsyncResult.t` attribute is deprecated, :class:`.Row` "
+        "now behaves like a tuple and can unpack types directly.",
+    )
     def t(self) -> AsyncTupleResult[Tuple[Unpack[_Ts]]]:
         """Apply a "typed tuple" typing filter to returned rows.
 
@@ -116,6 +122,12 @@ class AsyncResult(_WithKeys, AsyncCommon[Row[Unpack[_Ts]]]):
         """
         return self  # type: ignore
 
+    @deprecated(
+        "2.1.0",
+        "The :method:`.AsyncResult.tuples` method is deprecated, "
+        ":class:`.Row` now behaves like a tuple and can unpack types "
+        "directly.",
+    )
     def tuples(self) -> AsyncTupleResult[Tuple[Unpack[_Ts]]]:
         """Apply a "typed tuple" typing filter to returned rows.
 
index 62966c7870f7bad348666b41b30fe408a16e0728..b4a30128d1ca97a985cf2eaa0b0a2da9c57ef016 100644 (file)
@@ -90,6 +90,7 @@ from ..sql.selectable import HasPrefixes
 from ..sql.selectable import HasSuffixes
 from ..sql.selectable import LABEL_STYLE_TABLENAME_PLUS_COL
 from ..sql.selectable import SelectLabelStyle
+from ..util import deprecated
 from ..util.typing import Literal
 from ..util.typing import Self
 from ..util.typing import TypeVarTuple
@@ -297,6 +298,11 @@ class Query(
             for ent in util.to_list(entities)
         ]
 
+    @deprecated(
+        "2.1.0",
+        "The :method:`.Query.tuples` method is deprecated, :class:`.Row` "
+        "now behaves like a tuple and can unpack types directly.",
+    )
     def tuples(self: Query[_O]) -> Query[Tuple[_O]]:
         """return a tuple-typed form of this :class:`.Query`.