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

Class OperatorPrecedenceTest

test/sql/test_operators.py:1679–1917  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1677
1678
1679class OperatorPrecedenceTest(fixtures.TestBase, testing.AssertsCompiledSQL):
1680 __dialect__ = "default"
1681
1682 table1 = table(
1683 "mytable",
1684 column("myid", Integer),
1685 column("name", String),
1686 column("description", String),
1687 )
1688
1689 table2 = table("op", column("field"))
1690
1691 def test_operator_precedence_1(self):
1692 self.assert_compile(
1693 self.table2.select().where(
1694 (self.table2.c.field == 5) == None
1695 ), # noqa
1696 "SELECT op.field FROM op WHERE (op.field = :field_1) IS NULL",
1697 )
1698
1699 def test_operator_precedence_2(self):
1700 self.assert_compile(
1701 self.table2.select().where(
1702 (self.table2.c.field + 5) == self.table2.c.field
1703 ),
1704 "SELECT op.field FROM op WHERE op.field + :field_1 = op.field",
1705 )
1706
1707 def test_operator_precedence_3(self):
1708 self.assert_compile(
1709 self.table2.select().where((self.table2.c.field + 5) * 6),
1710 "SELECT op.field FROM op WHERE (op.field + :field_1) * :param_1",
1711 )
1712
1713 def test_operator_precedence_4(self):
1714 self.assert_compile(
1715 self.table2.select().where((self.table2.c.field * 5) + 6),
1716 "SELECT op.field FROM op WHERE op.field * :field_1 + :param_1",
1717 )
1718
1719 def test_operator_precedence_5(self):
1720 self.assert_compile(
1721 self.table2.select().where(5 + self.table2.c.field.in_([5, 6])),
1722 "SELECT op.field FROM op WHERE :param_1 + "
1723 "(op.field IN (__[POSTCOMPILE_field_1]))",
1724 )
1725
1726 def test_operator_precedence_6(self):
1727 self.assert_compile(
1728 self.table2.select().where((5 + self.table2.c.field).in_([5, 6])),
1729 "SELECT op.field FROM op WHERE :field_1 + op.field "
1730 "IN (__[POSTCOMPILE_param_1])",
1731 )
1732
1733 def test_operator_precedence_7(self):
1734 self.assert_compile(
1735 self.table2.select().where(
1736 not_(and_(self.table2.c.field == 5, self.table2.c.field == 7))

Callers

nothing calls this directly

Calls 2

tableFunction · 0.90
columnFunction · 0.90

Tested by

no test coverage detected