summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
diff options
context:
space:
mode:
authorjason3gb <jason3gb@gmail.com>2021-06-24 12:11:04 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-06-24 12:22:20 -0400
commit791f1d9407f68cc668c7078fa87784ebdf3bd688 (patch)
tree6d7a83795ddfe6e352899ea36105d306b62916a5 /lib/sqlalchemy/sql
parentfb141d9d5e3116dc233138fa0cf78ffdd05be87a (diff)
downloadsqlalchemy-791f1d9407f68cc668c7078fa87784ebdf3bd688.tar.gz
Add "impl" parameter to PickleType
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. Fixes: #6646 Closes: #6657 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6657 Pull-request-sha: e49bcd368d1f71dba92225d8d6e3af2bbe7142f7 Change-Id: Ib79f3b0ebbc94393f673f5a5ba6558260083d0cf
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r--lib/sqlalchemy/sql/sqltypes.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py
index 4f8654afd..4ae121163 100644
--- a/lib/sqlalchemy/sql/sqltypes.py
+++ b/lib/sqlalchemy/sql/sqltypes.py
@@ -1783,7 +1783,11 @@ class PickleType(TypeDecorator):
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.
@@ -1798,12 +1802,22 @@ class PickleType(TypeDecorator):
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)