MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / true

Function true

lib/sqlalchemy/sql/_elements_constructors.py:1695–1732  ·  view source on GitHub ↗

Return a constant :class:`.True_` construct. E.g.: .. sourcecode:: pycon+sql >>> from sqlalchemy import true >>> print(select(t.c.x).where(true())) {printsql}SELECT x FROM t WHERE true A backend which does not support true/false constants will render as an

()

Source from the content-addressed store, hash-verified

1693
1694
1695def true() -> True_:
1696 """Return a constant :class:`.True_` construct.
1697
1698 E.g.:
1699
1700 .. sourcecode:: pycon+sql
1701
1702 >>> from sqlalchemy import true
1703 >>> print(select(t.c.x).where(true()))
1704 {printsql}SELECT x FROM t WHERE true
1705
1706 A backend which does not support true/false constants will render as
1707 an expression against 1 or 0:
1708
1709 .. sourcecode:: pycon+sql
1710
1711 >>> print(select(t.c.x).where(true()))
1712 {printsql}SELECT x FROM t WHERE 1 = 1
1713
1714 The :func:`.true` and :func:`.false` constants also feature
1715 "short circuit" operation within an :func:`.and_` or :func:`.or_`
1716 conjunction:
1717
1718 .. sourcecode:: pycon+sql
1719
1720 >>> print(select(t.c.x).where(or_(t.c.x > 5, true())))
1721 {printsql}SELECT x FROM t WHERE true{stop}
1722
1723 >>> print(select(t.c.x).where(and_(t.c.x > 5, false())))
1724 {printsql}SELECT x FROM t WHERE false{stop}
1725
1726 .. seealso::
1727
1728 :func:`.false`
1729
1730 """
1731
1732 return True_._instance()
1733
1734
1735def tuple_(

Callers 15

test_sixMethod · 0.90
test_seven_aMethod · 0.90
test_seven_cMethod · 0.90
test_eightMethod · 0.90
test_nineMethod · 0.90
test_elevenMethod · 0.90
test_twelveMethod · 0.90
test_single_bool_oneMethod · 0.90
test_fiveMethod · 0.90
test_sixMethod · 0.90

Calls 1

_instanceMethod · 0.45

Tested by 15

test_sixMethod · 0.72
test_seven_aMethod · 0.72
test_seven_cMethod · 0.72
test_eightMethod · 0.72
test_nineMethod · 0.72
test_elevenMethod · 0.72
test_twelveMethod · 0.72
test_single_bool_oneMethod · 0.72
test_fiveMethod · 0.72
test_sixMethod · 0.72