MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / OperatorPrecedenceTest

Class OperatorPrecedenceTest

test/sql/test_operators.py:1831–2084  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1829
1830
1831class OperatorPrecedenceTest(fixtures.TestBase, testing.AssertsCompiledSQL):
1832 __dialect__ = "default"
1833
1834 table1 = table(
1835 "mytable",
1836 column("myid", Integer),
1837 column("name", String),
1838 column("description", String),
1839 )
1840
1841 table2 = table("op", column("field"))
1842
1843 def test_operator_precedence_1(self):
1844 self.assert_compile(
1845 self.table2.select().where(
1846 (self.table2.c.field == 5) == None
1847 ), # noqa
1848 "SELECT op.field FROM op WHERE (op.field = :field_1) IS NULL",
1849 )
1850
1851 def test_operator_precedence_2(self):
1852 self.assert_compile(
1853 self.table2.select().where(
1854 (self.table2.c.field + 5) == self.table2.c.field
1855 ),
1856 "SELECT op.field FROM op WHERE op.field + :field_1 = op.field",
1857 )
1858
1859 def test_operator_precedence_3(self):
1860 self.assert_compile(
1861 self.table2.select().where((self.table2.c.field + 5) * 6),
1862 "SELECT op.field FROM op WHERE (op.field + :field_1) * :param_1",
1863 )
1864
1865 def test_operator_precedence_4(self):
1866 self.assert_compile(
1867 self.table2.select().where((self.table2.c.field * 5) + 6),
1868 "SELECT op.field FROM op WHERE op.field * :field_1 + :param_1",
1869 )
1870
1871 def test_operator_precedence_5(self):
1872 self.assert_compile(
1873 self.table2.select().where(
1874 5 + type_coerce(self.table2.c.field.in_([5, 6]), Integer)
1875 ),
1876 "SELECT op.field FROM op WHERE :param_1 + "
1877 "(op.field IN (__[POSTCOMPILE_field_1]))",
1878 )
1879
1880 def test_operator_precedence_6(self):
1881 self.assert_compile(
1882 self.table2.select().where((5 + self.table2.c.field).in_([5, 6])),
1883 "SELECT op.field FROM op WHERE :field_1 + op.field "
1884 "IN (__[POSTCOMPILE_param_1])",
1885 )
1886
1887 def test_operator_precedence_7(self):
1888 self.assert_compile(

Callers

nothing calls this directly

Calls 2

tableFunction · 0.90
columnFunction · 0.90

Tested by

no test coverage detected