MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_comparator_null

Method test_comparator_null

test/orm/test_composites.py:1867–1891  ·  view source on GitHub ↗
(self, custom, op, fwd_op, rev_op)

Source from the content-addressed store, hash-verified

1865 argnames="op, fwd_op, rev_op",
1866 )
1867 def test_comparator_null(self, custom, op, fwd_op, rev_op):
1868 self._fixture(custom)
1869 Edge, Point = self.classes("Edge", "Point")
1870
1871 if op is operator.eq:
1872 self.assert_compile(
1873 select(Edge).filter(op(Edge.start, None)),
1874 "SELECT edge.id, edge.x1, edge.y1, edge.x2, edge.y2 FROM edge "
1875 "WHERE edge.x1 IS NULL AND edge.y1 IS NULL",
1876 checkparams={},
1877 )
1878 elif op is operator.ne:
1879 self.assert_compile(
1880 select(Edge).filter(op(Edge.start, None)),
1881 "SELECT edge.id, edge.x1, edge.y1, edge.x2, edge.y2 FROM edge "
1882 "WHERE edge.x1 IS NOT NULL AND edge.y1 IS NOT NULL",
1883 checkparams={},
1884 )
1885 else:
1886 with expect_raises_message(
1887 sa.exc.ArgumentError,
1888 r"Only '=', '!=', .* operators can be used "
1889 r"with None/True/False",
1890 ):
1891 select(Edge).filter(op(Edge.start, None))
1892
1893 def test_default_comparator_factory(self):
1894 self._fixture(False)

Callers

nothing calls this directly

Calls 6

_fixtureMethod · 0.95
selectFunction · 0.90
expect_raises_messageFunction · 0.90
opFunction · 0.85
assert_compileMethod · 0.80
filterMethod · 0.45

Tested by

no test coverage detected