Ticket #9307: oracle-pickle-v2.diff
File oracle-pickle-v2.diff, 2.3 KB (added by , 16 years ago) |
---|
-
django/db/models/sql/query.py
27 27 except NameError: 28 28 from sets import Set as set # Python 2.3 fallback 29 29 30 __all__ = ['Query' ]30 __all__ = ['Query', 'BaseQuery'] 31 31 32 class Query(object):32 class BaseQuery(object): 33 33 """ 34 34 A single SQL query. 35 35 """ … … 1747 1747 # Use the backend's custom Query class if it defines one. Otherwise, use the 1748 1748 # default. 1749 1749 if connection.features.uses_custom_query_class: 1750 Query = connection.ops.query_class(Query) 1750 Query = connection.ops.query_class(BaseQuery) 1751 else: 1752 Query = BaseQuery 1751 1753 1752 1754 def get_order_dir(field, default='ASC'): 1753 1755 """ -
django/db/backends/oracle/query.py
25 25 pass 26 26 27 27 class OracleQuery(QueryClass): 28 def __reduce__(self): 29 """ 30 Enable pickling for this class (normal pickling handling doesn't 31 work as Python can only pickle module-level classes by default). 32 """ 33 if hasattr(QueryClass, '__getstate__'): 34 assert hasattr(QueryClass, '__setstate__') 35 data = self.__getstate__() 36 else: 37 data = self.__dict__ 38 return (unpickle_query_class, (QueryClass,), data) 39 28 40 def resolve_columns(self, row, fields=()): 29 41 index_start = len(self.extra_select.keys()) 30 42 values = [self.convert_values(v, None) for v in row[:index_start]] … … 143 155 144 156 _classes[QueryClass] = OracleQuery 145 157 return OracleQuery 158 159 def unpickle_query_class(QueryClass): 160 """ 161 Utility function for handling unpickling of Oracle Query subclasses. This 162 is called by Python's unpickling functions. 163 """ 164 # FIXME: Would be nice to not have any dependency on cx_Oracle here. Since 165 # modules can't be pickled, we need a way to know to load the right module. 166 import cx_Oracle 167 168 klass = query_class(QueryClass, cx_Oracle) 169 return klass.__new__(klass) 170 unpickle_query_class.__safe_for_unpickling__ = True 171