]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- func. objects can be pickled/unpickled [ticket:844]
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 4 Nov 2007 22:04:22 +0000 (22:04 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 4 Nov 2007 22:04:22 +0000 (22:04 +0000)
CHANGES
lib/sqlalchemy/sql/expression.py
test/sql/select.py

diff --git a/CHANGES b/CHANGES
index 1d8a5301a0e2451ccb348cd64144ad29612de76c..0a1a65730f3a8e022044bf49ba60408ebe4f7405 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -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
index 67c1b727a991aa99168d7321a43d3aaf508ea4a5..22c296e98bcee5cb3941fd14b82b4616ae8d86bb 100644 (file)
@@ -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
index ace4557027794130f155825719bc63baaee07ed6..1999b52a0749f4c024aa86964d4c311203b6fef3 100644 (file)
@@ -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: