summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/expression.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2008-11-06 23:07:47 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2008-11-06 23:07:47 +0000
commitc3352e5542001d1a5614af260d74ad8757a59f26 (patch)
tree109a2af43b80ad3b244a3d1d8a395435d37eff3d /lib/sqlalchemy/sql/expression.py
parent84003a8d402c5d7539cf2d53f4061cde62d04413 (diff)
downloadsqlalchemy-c3352e5542001d1a5614af260d74ad8757a59f26.tar.gz
- Fixed bug in Query involving order_by() in conjunction with
multiple aliases of the same class (will add tests in [ticket:1218]) - Added a new extension sqlalchemy.ext.serializer. Provides Serializer/Deserializer "classes" which mirror Pickle/Unpickle, as well as dumps() and loads(). This serializer implements an "external object" pickler which keeps key context-sensitive objects, including engines, sessions, metadata, Tables/Columns, and mappers, outside of the pickle stream, and can later restore the pickle using any engine/metadata/session provider. This is used not for pickling regular object instances, which are pickleable without any special logic, but for pickling expression objects and full Query objects, such that all mapper/engine/session dependencies can be restored at unpickle time.
Diffstat (limited to 'lib/sqlalchemy/sql/expression.py')
-rw-r--r--lib/sqlalchemy/sql/expression.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py
index 85f229ba0..5206dc5fa 100644
--- a/lib/sqlalchemy/sql/expression.py
+++ b/lib/sqlalchemy/sql/expression.py
@@ -1002,6 +1002,11 @@ class ClauseElement(Visitable):
yield f
f = getattr(f, '_is_clone_of', None)
+ def __getstate__(self):
+ d = self.__dict__.copy()
+ d.pop('_is_clone_of', None)
+ return d
+
def _get_from_objects(self, **modifiers):
"""Return objects represented in this ``ClauseElement`` that
should be added to the ``FROM`` list of a query, when this
@@ -1959,7 +1964,17 @@ class _BindParamClause(ColumnElement):
"""
return isinstance(other, _BindParamClause) and other.type.__class__ == self.type.__class__
-
+
+ def __getstate__(self):
+ """execute a deferred value for serialization purposes."""
+
+ d = self.__dict__.copy()
+ v = self.value
+ if callable(v):
+ v = v()
+ d['value'] = v
+ return d
+
def __repr__(self):
return "_BindParamClause(%s, %s, type_=%s)" % (repr(self.key), repr(self.value), repr(self.type))