]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
added docs to case() illusrtating usage of `literal_column()`, can't implement #809...
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 28 Oct 2009 15:46:51 +0000 (15:46 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 28 Oct 2009 15:46:51 +0000 (15:46 +0000)
lib/sqlalchemy/sql/expression.py

index 9324ed6a089b28c1e699e4b9b55c4a82b0dd284a..4b49dc0bca429e4f03ad99a68c7352c6e05bf300 100644 (file)
@@ -437,7 +437,8 @@ def case(whens, value=None, else_=None):
     The expressions used for THEN and ELSE,
     when specified as strings, will be interpreted
     as bound values. To specify textual SQL expressions
-    for these, use the text(<string>) construct.
+    for these, use the literal_column(<string>) or 
+    text(<string>) construct. 
 
     The expressions used for the WHEN criterion
     may only be literal strings when "value" is
@@ -457,6 +458,15 @@ def case(whens, value=None, else_=None):
               'manager':  emp.c.salary * 3,
           })
 
+    Using ``literal_column()``, to allow for databases that
+    do not support bind parameters in the `then` clause.  The type
+    can be specified which determines the type of the `case()` construct
+    overall::
+    
+        case([(orderline.c.qty > 100, literal_column("'greaterthan100'", String)),
+              (orderline.c.qty > 10, literal_column("'greaterthan10'", String))
+            ], else_=literal_column("'lethan10'", String))
+
     """
     
     return _Case(whens, value=value, else_=else_)