From: Mike Bayer Date: Wed, 28 Oct 2009 15:46:51 +0000 (+0000) Subject: added docs to case() illusrtating usage of `literal_column()`, can't implement #809... X-Git-Tag: rel_0_6beta1~214 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b01d6341611d4457b70aa1f631abe8223bd16a57;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git added docs to case() illusrtating usage of `literal_column()`, can't implement #809 directly --- diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 9324ed6a08..4b49dc0bca 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -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() construct. + for these, use the literal_column() or + text() 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_)