MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_noorm

Method test_noorm

test/orm/test_assorted_eager.py:170–212  ·  view source on GitHub ↗

test the control case

(self, connection)

Source from the content-addressed store, hash-verified

168 session.flush()
169
170 def test_noorm(self, connection):
171 """test the control case"""
172
173 tests, options, categories = (
174 self.tables.tests,
175 self.tables.options,
176 self.tables.categories,
177 )
178
179 # I want to display a list of tests owned by owner 1
180 # if someoption is false or they haven't specified it yet (null)
181 # but not if they set it to true (example someoption is for hiding)
182
183 # desired output for owner 1
184 # test_id, cat_name
185 # 1 'Some Category'
186 # 3 "
187
188 # not orm style correct query
189 print("Obtaining correct results without orm")
190 result = connection.execute(
191 sa.select(tests.c.id, categories.c.name)
192 .where(
193 sa.and_(
194 tests.c.owner_id == 1,
195 sa.or_(
196 options.c.someoption == None, # noqa
197 options.c.someoption == False,
198 ),
199 )
200 )
201 .order_by(tests.c.id)
202 .select_from(
203 tests.join(categories).outerjoin(
204 options,
205 sa.and_(
206 tests.c.id == options.c.test_id,
207 tests.c.owner_id == options.c.owner_id,
208 ),
209 )
210 )
211 ).fetchall()
212 eq_(result, [(1, "Some Category"), (3, "Some Category")])
213
214 def test_withoutjoinedload(self):
215 Thing, tests, options = (

Callers

nothing calls this directly

Calls 11

eq_Function · 0.90
or_Method · 0.80
fetchallMethod · 0.45
executeMethod · 0.45
select_fromMethod · 0.45
order_byMethod · 0.45
whereMethod · 0.45
selectMethod · 0.45
and_Method · 0.45
outerjoinMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected