summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2023-03-07 00:25:59 +0100
committerMike Bayer <mike_mp@zzzcomputing.com>2023-03-10 10:26:26 -0500
commitfd9aa847920b9e4dff61ef7a5555c9fa6e362484 (patch)
tree9dc0046bd234cbf4ad2aadef658283787c6e107b /test/sql
parent9c0715181de6f03543c7ac9038c481f57f773d49 (diff)
downloadsqlalchemy-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 'test/sql')
-rw-r--r--test/sql/test_resultset.py42
1 files changed, 23 insertions, 19 deletions
diff --git a/test/sql/test_resultset.py b/test/sql/test_resultset.py
index 41bb81200..0537dc228 100644
--- a/test/sql/test_resultset.py
+++ b/test/sql/test_resultset.py
@@ -4,7 +4,11 @@ from contextlib import contextmanager
import csv
from io import StringIO
import operator
+import os
import pickle
+import subprocess
+import sys
+from tempfile import mkstemp
from unittest.mock import Mock
from unittest.mock import patch
@@ -502,25 +506,25 @@ class CursorResultTest(fixtures.TablesTest):
lambda: result[0]._mapping[addresses.c.address_id],
)
- # @testing.variation("use_labels", [True, False])
- # def _dont_test_pickle_rows_other_process(self, connection, use_labels):
- # result = self._pickle_row_data(connection, use_labels)
-
- # f, name = mkstemp("pkl")
- # with os.fdopen(f, "wb") as f:
- # pickle.dump(result, f)
- # name = name.replace(os.sep, "/")
- # code = (
- # "import sqlalchemy; import pickle; print(["
- # f"r[0] for r in pickle.load(open('''{name}''', 'rb'))])"
- # )
- # proc = subprocess.run(
- # [sys.executable, "-c", code], stdout=subprocess.PIPE
- # )
- # exp = str([r[0] for r in result]).encode()
- # eq_(proc.returncode, 0)
- # eq_(proc.stdout.strip(), exp)
- # os.unlink(name)
+ @testing.variation("use_labels", [True, False])
+ def test_pickle_rows_other_process(self, connection, use_labels):
+ result = self._pickle_row_data(connection, use_labels)
+
+ f, name = mkstemp("pkl")
+ with os.fdopen(f, "wb") as f:
+ pickle.dump(result, f)
+ name = name.replace(os.sep, "/")
+ code = (
+ "import sqlalchemy; import pickle; print(["
+ f"r[0] for r in pickle.load(open('''{name}''', 'rb'))])"
+ )
+ proc = subprocess.run(
+ [sys.executable, "-c", code], stdout=subprocess.PIPE
+ )
+ exp = str([r[0] for r in result]).encode()
+ eq_(proc.returncode, 0)
+ eq_(proc.stdout.strip(), exp)
+ os.unlink(name)
def test_column_error_printing(self, connection):
result = connection.execute(select(1))