MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_array

Method test_array

test/dialect/postgresql/test_compiler.py:1922–1972  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1920 )
1921
1922 def test_array(self):
1923 c = Column("x", postgresql.ARRAY(Integer))
1924
1925 self.assert_compile(
1926 cast(c, postgresql.ARRAY(Integer)), "CAST(x AS INTEGER[])"
1927 )
1928 self.assert_compile(
1929 c[5], "x[%(x_1)s::INTEGER]", checkparams={"x_1": 5}
1930 )
1931
1932 self.assert_compile(
1933 c[5:7],
1934 "x[%(x_1)s::INTEGER:%(x_2)s::INTEGER]",
1935 checkparams={"x_2": 7, "x_1": 5},
1936 )
1937 self.assert_compile(
1938 c[5:7][2:3],
1939 "x[%(x_1)s::INTEGER:%(x_2)s::INTEGER]"
1940 "[%(param_1)s::INTEGER:%(param_2)s::INTEGER]",
1941 checkparams={"x_2": 7, "x_1": 5, "param_1": 2, "param_2": 3},
1942 )
1943 self.assert_compile(
1944 c[5:7][3],
1945 "x[%(x_1)s::INTEGER:%(x_2)s::INTEGER][%(param_1)s::INTEGER]",
1946 checkparams={"x_2": 7, "x_1": 5, "param_1": 3},
1947 )
1948
1949 self.assert_compile(
1950 c.contains([1]),
1951 "x @> %(x_1)s::INTEGER[]",
1952 checkparams={"x_1": [1]},
1953 dialect=PGDialect_psycopg2(),
1954 )
1955 self.assert_compile(
1956 c.contained_by([2]),
1957 "x <@ %(x_1)s::INTEGER[]",
1958 checkparams={"x_1": [2]},
1959 dialect=PGDialect_psycopg2(),
1960 )
1961 self.assert_compile(
1962 c.contained_by([2]),
1963 "x <@ %(x_1)s",
1964 checkparams={"x_1": [2]},
1965 dialect=PGDialect(),
1966 )
1967 self.assert_compile(
1968 c.overlap([3]),
1969 "x && %(x_1)s::INTEGER[]",
1970 checkparams={"x_1": [3]},
1971 dialect=PGDialect_psycopg2(),
1972 )
1973
1974 def test_array_modern_any_all(self):
1975 c = Column("x", postgresql.ARRAY(Integer))

Callers

nothing calls this directly

Calls 8

ColumnClass · 0.90
castFunction · 0.90
PGDialect_psycopg2Class · 0.90
PGDialectClass · 0.90
assert_compileMethod · 0.80
overlapMethod · 0.80
containsMethod · 0.45
contained_byMethod · 0.45

Tested by

no test coverage detected