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

Class DefaultColumnComparatorTest

test/sql/test_operators.py:98–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96
97
98class DefaultColumnComparatorTest(
99 testing.AssertsCompiledSQL, fixtures.TestBase
100):
101 dialect = __dialect__ = "default_enhanced"
102
103 @testing.combinations((operators.desc_op, desc), (operators.asc_op, asc))
104 def test_scalar(self, operator, compare_to):
105 left = column("left")
106 assert left.comparator.operate(operator).compare(compare_to(left))
107 self._loop_test(operator)
108
109 right_column = column("right")
110
111 @testing.combinations(
112 (operators.add, right_column),
113 (operators.is_, None),
114 (operators.is_not, None),
115 (operators.isnot, None), # deprecated 1.4; See #5429
116 (operators.is_, null()),
117 (operators.is_, true()),
118 (operators.is_, false()),
119 (operators.eq, True),
120 (operators.ne, True),
121 (operators.is_distinct_from, True),
122 (operators.is_distinct_from, False),
123 (operators.is_distinct_from, None),
124 (operators.is_not_distinct_from, True),
125 (operators.isnot_distinct_from, True), # deprecated 1.4; See #5429
126 (operators.is_, True),
127 (operators.is_not, True),
128 (operators.isnot, True), # deprecated 1.4; See #5429
129 (operators.is_, False),
130 (operators.is_not, False),
131 (operators.isnot, False), # deprecated 1.4; See #5429
132 (operators.like_op, right_column),
133 (operators.not_like_op, right_column),
134 (operators.notlike_op, right_column), # deprecated 1.4; See #5435
135 (operators.ilike_op, right_column),
136 (operators.not_ilike_op, right_column),
137 (operators.notilike_op, right_column), # deprecated 1.4; See #5435
138 (operators.is_, right_column),
139 (operators.is_not, right_column),
140 (operators.isnot, right_column), # deprecated 1.4; See #5429
141 (operators.concat_op, right_column),
142 id_="ns",
143 )
144 def test_operate(self, operator, right):
145 left = column("left")
146
147 if operators.is_comparison(operator):
148 type_ = sqltypes.BOOLEANTYPE
149 else:
150 type_ = sqltypes.NULLTYPE
151
152 assert left.comparator.operate(operator, right).compare(
153 BinaryExpression(
154 coercions.expect(roles.WhereHavingRole, left),
155 coercions.expect(roles.WhereHavingRole, right),

Callers

nothing calls this directly

Calls 1

columnFunction · 0.90

Tested by

no test coverage detected