MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / true

Function true

lib/sqlalchemy/sql/_elements_constructors.py:1920–1957  ·  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

1918
1919
1920def true() -> True_:
1921 """Return a constant :class:`.True_` construct.
1922
1923 E.g.:
1924
1925 .. sourcecode:: pycon+sql
1926
1927 >>> from sqlalchemy import true
1928 >>> print(select(t.c.x).where(true()))
1929 {printsql}SELECT x FROM t WHERE true
1930
1931 A backend which does not support true/false constants will render as
1932 an expression against 1 or 0:
1933
1934 .. sourcecode:: pycon+sql
1935
1936 >>> print(select(t.c.x).where(true()))
1937 {printsql}SELECT x FROM t WHERE 1 = 1
1938
1939 The :func:`.true` and :func:`.false` constants also feature
1940 "short circuit" operation within an :func:`.and_` or :func:`.or_`
1941 conjunction:
1942
1943 .. sourcecode:: pycon+sql
1944
1945 >>> print(select(t.c.x).where(or_(t.c.x > 5, true())))
1946 {printsql}SELECT x FROM t WHERE true{stop}
1947
1948 >>> print(select(t.c.x).where(and_(t.c.x > 5, false())))
1949 {printsql}SELECT x FROM t WHERE false{stop}
1950
1951 .. seealso::
1952
1953 :func:`.false`
1954
1955 """
1956
1957 return True_._instance()
1958
1959
1960def 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