Viewing File: /opt/alt/python38/lib64/python3.8/site-packages/playhouse/__pycache__/shortcuts.cpython-38.pyc
U
SW# @ s d dl Z d dlT d dlmZ e jd dkr>d dlmZ dd Zddd Zd
d Zdd
Z dddZ
dddZG dd deZ
dS ) N)*)Node )Callablec C s
t | tS N)
isinstancer )c r
/shortcuts.py<lambda> r c C sx t dg}| dk }|r || |D ]"\}}|t d|t d|f q$|dk rb|t d|f |t d t| S )a&
CASE statement builder.
Example CASE statements:
SELECT foo,
CASE
WHEN foo = 1 THEN "one"
WHEN foo = 2 THEN "two"
ELSE "?"
END -- will be in column named "case" in postgres --
FROM bar;
-- equivalent to above --
SELECT foo,
CASE foo
WHEN 1 THEN "one"
WHEN 2 THEN "two"
ELSE "?"
END
Corresponding peewee:
# No predicate, use expressions.
Bar.select(Bar.foo, case(None, (
(Bar.foo == 1, "one"),
(Bar.foo == 2, "two")), "?"))
# Predicate, will test for equality.
Bar.select(Bar.foo, case(Bar.foo, (
(1, "one"),
(2, "two")), "?"))
ZCASENZWHENZTHENELSEZEND)SQLappendextendClause)Z predicateZexpression_tuplesdefaultZclausesZsimple_caseexprvaluer r r
case s "
r c C s t t| td| S )NzAS %s)fnZCASTr r )ZnodeZas_typer r r
cast<