summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2017-09-01 10:52:16 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2017-09-01 10:52:16 -0400
commit56845d8cc2678c0aefd889a7fc711150661cd8e8 (patch)
treec19515582b1057ba39e76f1a05b7cdbf6f9fba6b
parent3feea4503ff211cdd1f6046b4b8ae16cf0dd08a3 (diff)
downloadsqlalchemy-56845d8cc2678c0aefd889a7fc711150661cd8e8.tar.gz
include a note about the importance of type coerce for custom ops
Change-Id: Ia7dab65523d6a34fcc92ee785ffe03f7e2a33cfd
-rw-r--r--doc/build/core/tutorial.rst14
1 files changed, 12 insertions, 2 deletions
diff --git a/doc/build/core/tutorial.rst b/doc/build/core/tutorial.rst
index 9420441e3..432066980 100644
--- a/doc/build/core/tutorial.rst
+++ b/doc/build/core/tutorial.rst
@@ -617,7 +617,7 @@ The above illustrates the SQL that's generated for an
the ``||`` operator now compiles as MySQL's ``concat()`` function.
If you have come across an operator which really isn't available, you can
-always use the :meth:`.ColumnOperators.op` method; this generates whatever operator you need:
+always use the :meth:`.Operators.op` method; this generates whatever operator you need:
.. sourcecode:: pycon+sql
@@ -628,7 +628,17 @@ This function can also be used to make bitwise operators explicit. For example::
somecolumn.op('&')(0xff)
-is a bitwise AND of the value in `somecolumn`.
+is a bitwise AND of the value in ``somecolumn``.
+
+When using :meth:`.Operators.op`, the return type of the expression may be important,
+especialy when the operator is used in an expression that will be sent as a result
+column. For this case, be sure to make the type explicit, if not what's
+normally expected, using :func:`.type_coerce`::
+
+ from sqlalchemy import type_coerce
+ expr = type_coerce(somecolumn.op('-%>')('foo'), MySpecialType())
+ stmt = select([expr])
+
Operator Customization
----------------------