diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-11-04 22:04:22 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-11-04 22:04:22 +0000 |
| commit | 303e753b2d674d89f8277e8cd06dd0acf7094549 (patch) | |
| tree | 8f2c2630d8cad83e2047a57b10f5a35b27789116 | |
| parent | 8ebc8ee5bae0f4bef465e8b5b4b46609cfdebc10 (diff) | |
| download | sqlalchemy-303e753b2d674d89f8277e8cd06dd0acf7094549.tar.gz | |
- func. objects can be pickled/unpickled [ticket:844]
| -rw-r--r-- | CHANGES | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/expression.py | 8 | ||||
| -rw-r--r-- | test/sql/select.py | 3 |
3 files changed, 13 insertions, 0 deletions
@@ -27,6 +27,8 @@ CHANGES executes inline as normal but will not trigger a "postfetch" condition for the column, for those DB's who provide it via cursor.lastrowid + - func. objects can be pickled/unpickled [ticket:844] + - orm - eager loading with LIMIT/OFFSET applied no longer adds the primary table joined to a limited subquery of itself; the eager loads now diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 67c1b727a..22c296e98 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -2476,6 +2476,14 @@ class _ColumnElementAdapter(ColumnElement): def __getattr__(self, attr): return getattr(self.elem, attr) + def __getstate__(self): + return {'elem':self.elem, 'type':self.type, 'orig_set':self.orig_set} + + def __setstate__(self, state): + self.elem = state['elem'] + self.type = state['type'] + self.orig_set = state['orig_set'] + class _Grouping(_ColumnElementAdapter): """Represent a grouping within a column expression""" pass diff --git a/test/sql/select.py b/test/sql/select.py index ace455702..1999b52a0 100644 --- a/test/sql/select.py +++ b/test/sql/select.py @@ -691,6 +691,9 @@ FROM mytable, myothertable WHERE foo.id = foofoo(lala) AND datetime(foo) = Today # test None becomes NULL self.assert_compile(func.my_func(1,2,None,3), "my_func(:my_func, :my_func_1, NULL, :my_func_2)") + # test pickling + self.assert_compile(util.pickle.loads(util.pickle.dumps(func.my_func(1, 2, None, 3))), "my_func(:my_func, :my_func_1, NULL, :my_func_2)") + # assert func raises AttributeError for __bases__ attribute, since its not a class # fixes pydoc try: |
