]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
A couple of usage examples for the case statement
authorAnts Aasma <ants.aasma@gmail.com>
Thu, 3 Apr 2008 16:54:26 +0000 (16:54 +0000)
committerAnts Aasma <ants.aasma@gmail.com>
Thu, 3 Apr 2008 16:54:26 +0000 (16:54 +0000)
lib/sqlalchemy/sql/expression.py

index 39a2ae3eb93bb5d6b88882218caafc5903d3e3bb..9272e6d82cdc2c1d3891657f4eaff8a1de48844e 100644 (file)
@@ -440,6 +440,15 @@ def case(whens, value=None, else_=None):
     or literal(<string>) constructs must be used to 
     interpret raw string values.
       
+    Usage examples::
+
+      case([(orderline.c.qty > 100, item.c.specialprice),
+            (orderline.c.qty > 10, item.c.bulkprice)
+          ], else_=item.c.regularprice)
+      case(value=emp.c.type, whens={
+              'engineer': emp.c.salary * 1.1,
+              'manager':  emp.c.salary * 3,
+          })
     """
     try:
         whens = util.dictlike_iteritems(whens)