@compiles(greatest, 'oracle')
def case_greatest(element, compiler, **kw):
arg1, arg2 = list(element.clauses)
- return compiler.process(case([(arg1 > arg2, arg1)], else_=arg2), **kw)
+ return compiler.process(case((arg1 > arg2, arg1), else_=arg2), **kw)
Example usage::
discriminator: Mapped[str] = mapped_column(String(50))
__mapper_args__ = {
- "polymorphic_on":case([
+ "polymorphic_on":case(
(discriminator == "EN", "engineer"),
(discriminator == "MA", "manager"),
- ], else_="employee"),
+ else_="employee"),
"polymorphic_identity":"employee"
}
.. versionchanged:: 1.4 the :func:`_sql.case`
function now accepts the series of WHEN conditions positionally
- In the first form, it accepts a list of 2-tuples; each 2-tuple
- consists of ``(<sql expression>, <value>)``, where the SQL
- expression is a boolean expression and "value" is a resulting value,
- e.g.::
+ In the first form, it accepts multiple 2-tuples passed as positional
+ arguments; each 2-tuple consists of ``(<sql expression>, <value>)``,
+ where the SQL expression is a boolean expression and "value" is a
+ resulting value, e.g.::
case(
(users_table.c.name == 'wendy', 'W'),