diff options
| author | Federico Caselli <cfederico87@gmail.com> | 2023-03-07 00:25:59 +0100 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2023-03-10 10:26:26 -0500 |
| commit | fd9aa847920b9e4dff61ef7a5555c9fa6e362484 (patch) | |
| tree | 9dc0046bd234cbf4ad2aadef658283787c6e107b /lib/sqlalchemy/engine | |
| parent | 9c0715181de6f03543c7ac9038c481f57f773d49 (diff) | |
| download | sqlalchemy-fd9aa847920b9e4dff61ef7a5555c9fa6e362484.tar.gz | |
Fix regression when deserializing python rows into cython
Fixed regression involving pickling of Python rows between the cython and
pure Python implementations of :class:`.Row`, which occurred as part of
refactoring code for version 2.0 with typing. A particular constant were
turned into a string based ``Enum`` for the pure Python version of
:class:`.Row` whereas the cython version continued to use an integer
constant, leading to deserialization failures.
Regression occurred in a4bb502cf95ea3523e4d383c4377e50f402d7d52
Fixes: #9423
Change-Id: Icbd85cacb2d589cef7c246de7064249926146f2e
Diffstat (limited to 'lib/sqlalchemy/engine')
| -rw-r--r-- | lib/sqlalchemy/engine/_py_row.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/sqlalchemy/engine/_py_row.py b/lib/sqlalchemy/engine/_py_row.py index 7cbac552f..1b952fe4c 100644 --- a/lib/sqlalchemy/engine/_py_row.py +++ b/lib/sqlalchemy/engine/_py_row.py @@ -24,7 +24,7 @@ if typing.TYPE_CHECKING: MD_INDEX = 0 # integer index in cursor.description -class _KeyStyle(enum.Enum): +class _KeyStyle(enum.IntEnum): KEY_INTEGER_ONLY = 0 """__getitem__ only allows integer values and slices, raises TypeError otherwise""" @@ -121,6 +121,9 @@ class BaseRow: mdindex = rec[MD_INDEX] if mdindex is None: self._parent._raise_for_ambiguous_column_name(rec) + # NOTE: keep "== KEY_OBJECTS_ONLY" instead of "is KEY_OBJECTS_ONLY" + # since deserializing the class from cython will load an int in + # _key_style, not an instance of _KeyStyle elif self._key_style == KEY_OBJECTS_ONLY and isinstance(key, int): raise KeyError(key) |
