--- /dev/null
+.. change::
+ :tags: usecase, sql
+ :tickets: 6646
+
+ Add a impl parameter to :class:`_types.PickleType` constructor, allowing
+ any arbitary type to be used in place of the default implementation of
+ :class:`_types.LargeBinary`. Pull request courtesy jason3gb.
\ No newline at end of file
cache_ok = True
def __init__(
- self, protocol=pickle.HIGHEST_PROTOCOL, pickler=None, comparator=None
+ self,
+ protocol=pickle.HIGHEST_PROTOCOL,
+ pickler=None,
+ comparator=None,
+ impl=None,
):
"""
Construct a PickleType.
to compare values of this type. If left as ``None``,
the Python "equals" operator is used to compare values.
+ :param impl: A binary-storing :class:`_types.TypeEngine` class or
+ instance to use in place of the default :class:`_types.LargeBinary`.
+ For example the :class: `_mysql.LONGBLOB` class may be more effective
+ when using MySQL.
+
+ .. versionadded:: 1.4.20
+
"""
self.protocol = protocol
self.pickler = pickler or pickle
self.comparator = comparator
super(PickleType, self).__init__()
+ if impl:
+ self.impl = to_instance(impl)
+
def __reduce__(self):
return PickleType, (self.protocol, None, self.comparator)
):
assert p1.compare_values(p1.copy_value(obj), obj)
+ @testing.combinations(
+ None, mysql.LONGBLOB, LargeBinary, mysql.LONGBLOB(), LargeBinary()
+ )
+ def test_customized_impl(self, impl):
+ """test #6646"""
+
+ if impl is None:
+ p1 = PickleType()
+ assert isinstance(p1.impl, LargeBinary)
+ else:
+ p1 = PickleType(impl=impl)
+
+ if not isinstance(impl, type):
+ impl = type(impl)
+
+ assert isinstance(p1.impl, impl)
+
class CallableTest(fixtures.TestBase):
@testing.provide_metadata