diff options
| -rw-r--r-- | doc/build/sqlexpression.rst | 6 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/expression.py | 10 |
2 files changed, 14 insertions, 2 deletions
diff --git a/doc/build/sqlexpression.rst b/doc/build/sqlexpression.rst index b6acf2343..19598f29c 100644 --- a/doc/build/sqlexpression.rst +++ b/doc/build/sqlexpression.rst @@ -426,6 +426,12 @@ If you have come across an operator which really isn't available, you can always >>> print users.c.name.op('tiddlywinks')('foo') users.name tiddlywinks :name_1 +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`. + Conjunctions ============= diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index cf08ec195..a1ebb179f 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -1506,11 +1506,17 @@ class _CompareMixin(ColumnOperators): somecolumn * 5 - operator - a string which will be output as the infix operator between + + :param operator: a string which will be output as the infix operator between this ``ClauseElement`` and the expression passed to the generated function. + 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. + """ return lambda other: self.__operate(operator, other) |
