ok
Direktori : /opt/alt/python38/lib64/python3.8/site-packages/playhouse/__pycache__/ |
Current File : //opt/alt/python38/lib64/python3.8/site-packages/playhouse/__pycache__/shortcuts.cpython-38.pyc |
U S��W# � @ s� d dl Z d dlT d dlmZ e jd dkr>d dlmZ dd� Zddd �Zd d� Zdd � Z ddd�Z ddd�ZG dd� de�Z dS )� N)�*)�Node� )�Callablec C s t | t�S �N)� isinstancer )�c� r � /shortcuts.py�<lambda> � r c C sx t d�g}| 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")), "?")) ZCASENZWHENZTHEN�ELSEZEND)�SQL�append�extend�Clause)Z predicateZexpression_tuples�defaultZclausesZsimple_case�expr�valuer r r �case s " r c C s t �t| td| ���S )NzAS %s)�fnZCASTr r )ZnodeZas_typer r r �cast<