as well as any other non-migrated applications. Previously, this would
raise :class:`.ResourceClosedException` unconditionally in the same way as
it does when attempting to fetch rows. While this is the correct behavior
- going forward, the :class:`_cursor.LegacyCursorResult` object will now in
+ going forward, the ``LegacyCursorResult`` object will now in
this case return an empty list for ``.keys()`` as it did in 1.3, while also
emitting a 2.0 deprecation warning. The :class:`_cursor.CursorResult`, used
when using a 2.0-style "future" engine, will continue to raise as it does
works as it would with a dictionary, rather than raising ``TypeError`` as
would be the case with a tuple, whether or not the C extensions are in
place. This was originally supposed to emit a 2.0 deprecation warning for
- the "non-future" case using :class:`_result.LegacyRow`, and was to raise
+ the "non-future" case using ``LegacyRow``, and was to raise
``TypeError`` for the "future" :class:`_result.Row` class. However, the C
version of :class:`_result.Row` was failing to raise this ``TypeError``,
and to complicate matters, the :meth:`_orm.Session.execute` method now
Therefore, in order to soften the overall upgrade scheme as most users have
not been exposed to the more strict behavior of :class:`_result.Row` up
- through 1.4.6, :class:`_result.LegacyRow` and :class:`_result.Row` both
+ through 1.4.6, ``LegacyRow`` and :class:`_result.Row` both
provide for string-key access as well as support for ``dict(row)``, in all
cases emitting the 2.0 deprecation warning when ``SQLALCHEMY_WARN_20`` is
enabled. The :class:`_result.Row` object still uses tuple-like behavior for
``__contains__``, which is probably the only noticeable behavioral change
- compared to :class:`_result.LegacyRow`, other than the removal of
+ compared to ``LegacyRow``, other than the removal of
dictionary-style methods ``values()`` and ``items()``.
.. change::
Restored the :class:`_engine.ResultProxy` name back to the
``sqlalchemy.engine`` namespace. This name refers to the
- :class:`_engine.LegacyCursorResult` object.
+ ``LegacyCursorResult`` object.
.. change::
:tags: bug, orm
and ``index`` will be served as tuple values if the named tuple includes
those names; if they are absent, then their behavior as methods of
``collections.abc.Sequence`` is maintained. Therefore the
- :class:`_result.Row` and :class:`_result.LegacyRow` classes have been fixed
+ :class:`_result.Row` and ``LegacyRow`` classes have been fixed
so that they work in this same way, maintaining the expected behavior for
database rows that have columns named "index" or "count".
Python-level value processors have been simplified, particularly as it impacts the
format of the C code, so that a DBAPI row is processed into a result tuple
up front. The object returned by the :class:`_engine.ResultProxy` is now the
- :class:`.LegacyRow` subclass, which maintains mapping/tuple hybrid behavior,
+ ``LegacyRow`` subclass, which maintains mapping/tuple hybrid behavior,
however the base :class:`.Row` class now behaves more fully like a named
tuple.
Core :class:`.Row` class, which behaves in the same way as KeyedTuple.
In SQLAlchemy 2.0, both Core and ORM will return result rows using the same
:class:`.Row` object. In the interim, Core uses a backwards-compatibility
- class :class:`.LegacyRow` that maintains the former mapping/tuple hybrid
+ class ``LegacyRow`` that maintains the former mapping/tuple hybrid
behavior used by "RowProxy".
.. seealso::
:ref:`change_4710_orm` describes the ORM's use of the :class:`.Row` class.
For release 1.4, the :class:`.Row` class provides an additional subclass
-:class:`.LegacyRow`, which is used by Core and provides a backwards-compatible
+``LegacyRow``, which is used by Core and provides a backwards-compatible
version of :class:`.RowProxy` while emitting deprecation warnings for those API
features and behaviors that will be moved. ORM :class:`_query.Query` now makes use
of :class:`.Row` directly as a replacement for :class:`.KeyedTuple`.
-The :class:`.LegacyRow` class is a transitional class where the
+The ``LegacyRow`` class is a transitional class where the
``__contains__`` method is still testing against the keys, not the values,
while emitting a deprecation warning when the operation succeeds.
Additionally, all the other mapping-like methods on the previous
-:class:`.RowProxy` are deprecated, including :meth:`.LegacyRow.keys`,
-:meth:`.LegacyRow.items`, etc. For mapping-like behaviors from a :class:`.Row`
+:class:`.RowProxy` are deprecated, including ``LegacyRow.keys()``,
+``LegacyRow.items()``, etc. For mapping-like behaviors from a :class:`.Row`
object, including support for these methods as well as a key-oriented
``__contains__`` operator, the API going forward will be to first access a
special attribute :attr:`.Row._mapping`, which will then provide a complete
"id" in row # True for a mapping, False for a named tuple
"some name" in row # False for a mapping, True for a named tuple
-In 1.4, when a :class:`.LegacyRow` is returned by a Core result set, the above
+In 1.4, when a ``LegacyRow`` is returned by a Core result set, the above
``"id" in row`` comparison will continue to succeed, however a deprecation
warning will be emitted. To use the "in" operator as a mapping, use the
:attr:`.Row._mapping` attribute::
will return result rows using the same :class:`.Row` object which behaves like
a named tuple. Dictionary-like functionality is available from :class:`.Row`
via the :attr:`.Row._mapping` attribute. In the interim, Core result sets
-will make use of a :class:`.Row` subclass :class:`.LegacyRow` which maintains
+will make use of a :class:`.Row` subclass ``LegacyRow`` which maintains
the previous dict/tuple hybrid behavior for backwards compatibility while the
:class:`.Row` class will be used directly for ORM tuple results returned
by the :class:`_query.Query` object.
import warnings
from sqlalchemy import exc
-
+
# for warnings not included in regex-based filter below, just log
warnings.filterwarnings(
"always", category=exc.RemovedIn20Warning
)
-
+
# for warnings related to execute() / scalar(), raise
for msg in [
r"The (?:Executable|Engine)\.(?:execute|scalar)\(\) function",
back with Core statement results when using the
:paramref:`_sa.create_engine.future` flag with :class:`_engine.Engine` (when
the :paramref:`_sa.create_engine.future` flag is not set, Core result sets use
-the :class:`.LegacyRow` subclass, which maintains backwards-compatible
+the ``LegacyRow`` subclass, which maintains backwards-compatible
behaviors for the ``__contains__()`` method; ORM exclusively uses the
:class:`.Row` class directly).