MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_select_from_bindparam

Method test_select_from_bindparam

test/sql/test_query.py:325–348  ·  view source on GitHub ↗

Test result row processing when selecting from a plain bind param.

(self, connection)

Source from the content-addressed store, hash-verified

323
324 @testing.requires.standalone_binds
325 def test_select_from_bindparam(self, connection):
326 """Test result row processing when selecting from a plain bind
327 param."""
328
329 class MyInteger(TypeDecorator):
330 impl = Integer
331 cache_ok = True
332
333 def process_bind_param(self, value, dialect):
334 return int(value[4:])
335
336 def process_result_value(self, value, dialect):
337 return "INT_%d" % value
338
339 eq_(
340 connection.scalar(select(cast("INT_5", type_=MyInteger))),
341 "INT_5",
342 )
343 eq_(
344 connection.scalar(
345 select(cast("INT_5", type_=MyInteger).label("foo"))
346 ),
347 "INT_5",
348 )
349
350 def test_order_by(self, connection):
351 """Exercises ORDER BY clause generation.

Callers

nothing calls this directly

Calls 5

eq_Function · 0.90
selectFunction · 0.90
castFunction · 0.90
scalarMethod · 0.45
labelMethod · 0.45

Tested by

no test coverage detected