summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-10-24 16:13:32 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2013-10-24 16:13:32 -0400
commit3a4567a718c2f9f3d8b65acb81f0caefb4f1a2b5 (patch)
treef73ded16750da5e0f3cdafab6109e484708d237f /lib/sqlalchemy/sql
parentf0678a6e54e9598b884b82f43e57f44661693cca (diff)
downloadsqlalchemy-3a4567a718c2f9f3d8b65acb81f0caefb4f1a2b5.tar.gz
- add migration notes for [ticket:2838]
- have TypeDecorator use process_bind_param for literal values if no process_literal_param is set
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r--lib/sqlalchemy/sql/type_api.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/type_api.py b/lib/sqlalchemy/sql/type_api.py
index 698e17472..5d81e4a0c 100644
--- a/lib/sqlalchemy/sql/type_api.py
+++ b/lib/sqlalchemy/sql/type_api.py
@@ -793,11 +793,29 @@ class TypeDecorator(TypeEngine):
Subclasses here will typically override :meth:`.TypeDecorator.process_literal_param`
instead of this method directly.
+ By default, this method makes use of :meth:`.TypeDecorator.process_bind_param`
+ if that method is implemented, where :meth:`.TypeDecorator.process_literal_param`
+ is not. The rationale here is that :class:`.TypeDecorator` typically deals
+ with Python conversions of data that are above the layer of database
+ presentation. With the value converted by :meth:`.TypeDecorator.process_bind_param`,
+ the underlying type will then handle whether it needs to be presented to the
+ DBAPI as a bound parameter or to the database as an inline SQL value.
+
.. versionadded:: 0.9.0
"""
if self._has_literal_processor:
process_param = self.process_literal_param
+ elif self._has_bind_processor:
+ # the bind processor should normally be OK
+ # for TypeDecorator since it isn't doing DB-level
+ # handling, the handling here won't be different for bound vs.
+ # literals.
+ process_param = self.process_bind_param
+ else:
+ process_param = None
+
+ if process_param:
impl_processor = self.impl.literal_processor(dialect)
if impl_processor:
def process(value):