diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-10-13 12:00:52 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-10-13 13:52:23 -0400 |
| commit | 53ad3cf4e9b02f841fff960ec95870110f6c7bcb (patch) | |
| tree | 61695ea261585be3b555817dbe3d92554f38704f /test/sql | |
| parent | de9db9940fbcf32ccd93169d2ed6aa874869b84d (diff) | |
| download | sqlalchemy-53ad3cf4e9b02f841fff960ec95870110f6c7bcb.tar.gz | |
Pickling fixes for ORM / Core
Fixed regression where ORM loaded objects could not be pickled in cases
where loader options making use of ``"*"`` were used in certain
combinations, such as combining the :func:`_orm.joinedload` loader strategy
with ``raiseload('*')`` of sub-elements.
Fixes: #7134
Fixed issue where SQL queries using the
:meth:`_functions.FunctionElement.within_group` construct could not be
pickled, typically when using the ``sqlalchemy.ext.serializer`` extension
but also for general generic pickling.
Fixes: #6520
Change-Id: Ib73fd49c875e6da9898493c190f610e68b88ec72
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_functions.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/sql/test_functions.py b/test/sql/test_functions.py index 43b505c99..f3fb724c0 100644 --- a/test/sql/test_functions.py +++ b/test/sql/test_functions.py @@ -542,6 +542,31 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): "row_number() OVER ()", ) + def test_pickle_within_group(self): + """test #6520""" + + # TODO: the test/sql package lacks a comprehensive pickling + # test suite even though there are __reduce__ methods in several + # places in sql/elements.py. likely as part of + # test/sql/test_compare.py might be a place this can happen but + # this still relies upon a strategy for table metadata as we have + # in serializer. + + f1 = func.percentile_cont(literal(1)).within_group() + + self.assert_compile( + util.pickle.loads(util.pickle.dumps(f1)), + "percentile_cont(:param_1) WITHIN GROUP (ORDER BY )", + ) + + f1 = func.percentile_cont(literal(1)).within_group( + column("q"), column("p").desc() + ) + self.assert_compile( + util.pickle.loads(util.pickle.dumps(f1)), + "percentile_cont(:param_1) WITHIN GROUP (ORDER BY q, p DESC)", + ) + def test_functions_with_cols(self): users = table( "users", column("id"), column("name"), column("fullname") |
